简体   繁体   中英

saving image in ggplot & ggmap

i have saved an image using ggsave function which look as below 在此输入图像描述

but i want to have output like this 在此输入图像描述

       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)

i tried to removed x and y axis values but problem is that image have white background at the panel but i want only plot image.

In the ggmap() function, you need extent = "device" . See ?ggmap::ggmap for more options.

The following will give the result you want.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM