在ggplot&中保存图像ggmap

时间:2012-07-21 07:04:34

标签: r ggplot2 ggmap

我使用ggsave函数保存了一个图像,如下所示 enter image description here

但我希望有这样的输出 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轴值,但问题是图像在面板上有白色背景但我只想要绘制图像。

1 个答案:

答案 0 :(得分:5)

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)