2012-07-21 66 views
6

我一直在使用ggsave函數如下 enter image description here保存圖像在ggplot&ggmap

看保存的圖像,但我想有這樣 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軸值,但問題是該圖像在面板上有白色背景,但我只想繪製圖像。

回答

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)