hughjonesd / ggmagnify

Create a magnified inset of part of a ggplot object

Home Page:https://hughjonesd.github.io/ggmagnify/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Screws up when multiple polygons are magnified

hughjonesd opened this issue · comments

For a map:

library(ggplot2)
library(ggmagnify)
usa <- sf::st_as_sf(maps::map("state", fill=TRUE, plot =FALSE))

ggpm <- ggplot(usa) + geom_sf() +
         coord_sf(default_crs = sf::st_crs(4326), ylim = c(10, 50)) 


ggpm + geom_magnify(aes(from = ID %in% c("texas", "arizona")),
                    to = c(-125, -98, 10, 30), 
                    shape = "outline", 
                    aspect = "fixed", 
                    expand = 0) 

image

This could be fixed better by doing each polygon separately; but there'd probably need to be an option for that!