ggplot2 - Join two ggmap with R -


i tried replicate following image appeared in another question, can't merge 2 maps:

i have use annotation_custom not work:

library(raster);library(ggmap) library(ggplot2) library(ggthemes)  g_canarias <- ggplotgrob(   ggmap( get_map( location = c(lon = mean(c(-18.3, -13.15)),                            lat = mean(c(27.5, 29.55))),               zoom = 6,               maptype = "satellite") ) +   scale_x_continuous(limits = c(-18.3, -13.15), expand = c(0, 0)) +   scale_y_continuous(limits = c(27.5, 29.55), expand = c(0, 0)) +   theme_bw() +    theme(legend.position = "none",     plot.background = element_rect(colour = "black"),     # plot.margin = margin(0, 0, 0, 0),     axis.title.x = element_blank(),     axis.title.y = element_blank()) )  ggmap( get_map( location = c(lon = mean(c(-9.5, 4.5)),                          lat = mean(c(35, 44))),             zoom = 6,             maptype = "satellite") ) +   scale_x_continuous(limits = c(-9.5, 4.5), expand = c(0, 0)) +   scale_y_continuous(limits = c(35, 44), expand = c(0, 0)) +   xlab("longitud") + ylab("latitud") +   theme_bw() +    theme(legend.position = "none") 

here's abstract example (as yours not reproducible):

library(ggmap) hdf <- get_map("houston, texas") bb <- unlist(attr(hdf, "bb")) bb <- c(bb[2], bb[2]+diff(bb[c(2,4)])/3, bb[3]-diff(bb[c(1,3)])/3, bb[3]) ggmap(hdf, extent = "normal") +    annotation_raster(hdf, bb[1], bb[2], bb[3], bb[4]) +    annotate("rect", xmin=bb[1], xmax=bb[2], ymin=bb[3], ymax=bb[4], fill=na, color="black", size=1) +    coord_quickmap() 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -