首页 文章

在ggplot和ggmap中保存图像

提问于
浏览
6

我使用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 回答

  • 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)
    

相关问题