Saving image in ggplot & ggmap

I saved the image using the ggsave function that look below enter image description here

but I want to have this conclusion 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) 

I tried to remove the x and y axis values, but the problem is that the image has a white background in the panel, but I only want the image with the image.

+6
source share
1 answer

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

Below is 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) 
+4
source

Source: https://habr.com/ru/post/921015/


All Articles