簡體   English   中英

在ggplot和ggmap中保存圖像

[英]saving image in ggplot & ggmap

我使用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軸值但問題是圖像在面板上有白色背景但我只想要繪圖圖像。

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM