R geom_段和ggmap中的alpha设置似乎不起作用
在geom_段和ggmap中设置alpha时,该段突然消失。 下面的代码没有显示段,但是如果我删除alpha设置(注释行),则会显示段 我正在使用:R geom_段和ggmap中的alpha设置似乎不起作用,r,ggplot2,ggmap,R,Ggplot2,Ggmap,在geom_段和ggmap中设置alpha时,该段突然消失。 下面的代码没有显示段,但是如果我删除alpha设置(注释行),则会显示段 我正在使用: R版本3.2.4 ggmap_2.6.1 ggplot2_2.1.0 (我怀疑问题可能与库的版本有关) 代码: bbox可能您的设备不支持透明度。绘图(1:10,col=“#FF0000B4”,cex=2,pch=15,ty=“l”)是否生成带直线的绘图?.Device的输出是什么?非常感谢您的回答。您的代码生成一个带有线条的绘图。我还试图从代
- R版本3.2.4
- ggmap_2.6.1
- ggplot2_2.1.0
bbox可能您的设备不支持透明度。绘图(1:10,col=“#FF0000B4”,cex=2,pch=15,ty=“l”)
是否生成带直线的绘图?.Device
的输出是什么?非常感谢您的回答。您的代码生成一个带有线条的绘图。我还试图从代码中删除extent='device',现在alpha设置起作用了(我是R新手--我真的不知道extent='device'意味着什么!)!唯一的问题是,当extent='device'时,图例显示在地图上,而现在它在地图外面。我将寻找解决方案,感谢hintI在运行代码后仍然保留该部分。我使用的是ggmap_2.6 ggplot2_2.1.0
bbox<-c(8.5,44.68,11.43,46.64);
start_lat<-c(bbox[2]);
start_lon<-c(bbox[1]);
end_lat<-c(bbox[4]);
end_lon<-c(bbox[3]);
w<-c(1);
amap <- c(bbox);
z<-data.frame(start_lon,start_lat,end_lon,end_lat,w);
amap.map = get_map(location = amap, maptype='terrain', color='bw');
xx = ggmap(amap.map, extent = 'device', legend='bottomright');
#xx = xx + geom_segment(data=z, aes(x=start_lon,y=start_lat,xend=end_lon,yend=end_lat, size=w, colour=w));
xx = xx + geom_segment(data=z, aes(x=start_lon,y=start_lat,xend=end_lon,yend=end_lat, alpha=0.5,size=w, colour=w));
xx