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

coord_quickmap does not work with inset_element() #214

Closed
richardvogg opened this issue Nov 9, 2020 · 3 comments
Closed

coord_quickmap does not work with inset_element() #214

richardvogg opened this issue Nov 9, 2020 · 3 comments

Comments

@richardvogg
Copy link

I really, really like the new inset_element() function in patchwork.

This is not a big issue, but I noticed that when I am using coord_quickmap() in a plot, inset_element() does not work.

Small example:

`library(ggplot2)

test <- ggplot()+borders(regions="france")+coord_quickmap()
test + inset_element(test,0.1,0.1,0.5,0.5)
`

Error in seq.default(design$t[i], design$b[i]) :
'from' must be a finite number

The same without coord_quickmap() works.

@tomjemmett
Copy link

I seem to be having same issue with {sf}, reprex:

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(ggplot2)
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(patchwork)

nc <- system.file("shape", package = "sf") %>%
  st_read("nc")
#> Reading layer `nc' from data source `C:\Program Files\R\R-4.0.3\library\sf\shape' using driver `ESRI Shapefile'
#> Simple feature collection with 100 features and 14 fields
#> geometry type:  MULTIPOLYGON
#> dimension:      XY
#> bbox:           xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
#> geographic CRS: NAD27

p <- ggplot(nc) + geom_sf()

p + inset_element(p, 0, 0, 0.5, 0.5)
#> Error in seq.default(design$t[i], design$b[i]): 'from' must be a finite number

@jaseeverett
Copy link

Thanks for the great inset update @thomasp85. Its a great idea and will simplify insets maps greatly. Unfortunately I can confirm this doesn't work with an sf plot. I have my own code, but I have also tested @tomjemmett reprex above. Both give the same error #> Error in seq.default(design$t[i], design$b[i]): 'from' must be a finite number

@AllanCameron
Copy link

Related - see this stack overflow post which tracks this bug to set_panel_dimensions and shows a quick & dirty workaround

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

4 participants