Search code examples
rggplot2ggmap

Overlaying ggmap and ggplot


I am trying to display ggplot on top of ggmap.

library(patchwork)
ggmap(seoul) + ggplot(data = install_time_df) +
  geom_point(aes(x = long, y = lat, size = capa_sum),
             color = "black", alpha = 0.55)

I have tried patchwork library, but it displays them side by side not overlaying on the same display. enter image description here

Without patchwork, I get the following error message:

Error : Can't add gg_heat to a ggplot object. Run rlang::last_error() to see where the error occurred.


Solution

  • You can use something like following

    ggmap(seoul) + 
      geom_point(data = install_time_df, aes(x = long, y = lat, size = capa_sum),
                 color = "black", alpha = 0.55)