我使用ggsave函数保存了一个图像,如下所示
但我希望有这样的输出
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轴值,但问题是图像在面板上有白色背景但我只想要绘制图像。
答案 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)