Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using facet_zoom with coord_quickmap #56

Open
restonslacker opened this issue Feb 1, 2017 · 0 comments
Open

using facet_zoom with coord_quickmap #56

restonslacker opened this issue Feb 1, 2017 · 0 comments

Comments

@restonslacker
Copy link

Is there a nice way to combine facet_zoom with coord_quickmap? I'd like to have a combination of the first plot with a zoom in around the UK. When I try to use facet_zoom, I can either forgo the call to coord_quickmap and get the correct zoom, but a weird aspect ratio (ex 2) or I can include coord_quickmap but then while the zoom facet has the right aspect ratio, it shows the whole map (ex 3)

library(ggforce)
#> Loading required package: ggplot2
library(maps)

global_map <- map_data("world")

point_data <- data.frame(lng = c(runif(50, -10, -3), runif(50, -50, -3)), lat = c(runif(50, 
  54, 60), runif(50, 54, 65)))

p <- ggplot() + geom_polygon(aes(x = long, y = lat, group = group), fill = "#4FFFB0", 
  colour = NA, data = global_map) + theme(panel.grid = element_blank(), panel.background = element_rect(fill = "#0087BD")) + 
  geom_point(aes(x = lng, y = lat, colour = pct_change), colour = "yellow", 
    data = point_data)

p + coord_quickmap(xlim = c(-52.25, -5), ylim = c(54.5, 64.5))

p + facet_zoom(xlim = c(-10, -3), ylim = c(54, 60), horizontal = FALSE)

p + facet_zoom(xlim = c(-10, -3), ylim = c(54, 60), horizontal = FALSE) + coord_quickmap(xlim = c(-52.25, 
  -5), ylim = c(54.5, 64.5))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant