2012-07-21 72 views
6

我一直在使用ggsave函数如下 enter image description here保存图像在ggplot&ggmap

看保存的图像,但我想有这样 enter image description here

 al1 <- get_map(location = c(lon = -86.304474, lat = 32.362563), zoom = 11, maptype = 'terrain') 

     lon<--86.304474 
     lat<-32.362563 
     df<-data.frame(lon,lat) 
     a+ggplot(df) 
     ggmap(al1)+geom_point(data=df,aes(x=lon,y=lat),size=2) 

输出我试图删除x和Y轴值,但问题是该图像在面板上有白色背景,但我只想绘制图像。

回答

4

ggmap()函数中,您需要extent = "device"。有关更多选项,请参阅?ggmap::ggmap

以下将给出你想要的结果。

library(ggmap) 
al1 <- get_map(location = c(lon = -86.304474, lat = 32.362563), zoom = 11, maptype = 'terrain') 

lon<--86.304474 
lat<-32.362563 
df<-data.frame(lon,lat) 
     #a+ggplot(df) # Not sure what you intend here 
ggmap(al1, extent = "device")+geom_point(data=df,aes(x=lon,y=lat),size=2)