patchwork
patchwork copied to clipboard
Facet_geo implementation
Hi guys. I tried to implement patchwork with the geofacet package.
Geofacet creates a map-like arrangement of geom_facet() instances so that you can geographically plot data.
My original plot looked something like this
When adding in patchwork to make a summation chart on the right, something about patchwork's grid alignment code un-hid the additional facets that facet_geo creates in the background: https://imgur.com/NwlKXmK
getting two complex packages like this to play along is probably too much to ask, but I thought I should throw it out there.
This might be also related to an issue I found using facet_nested() from the ggh4x package (https://github.com/teunbrand/ggh4x/)
library(ggplot2)
library(patchwork)
mg <- ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point()
g <- mg + ggh4x::facet_nested(vs + am ~ gear, margins = TRUE)
Works fine
g

Error!
g + g
#> Error in grid.Call.graphics(C_setviewport, vp, TRUE): invalid 'layout.pos.col'
So this might be a more general issue with customised facets? (also similar to this: https://github.com/thomasp85/patchwork/issues/149 )
Created on 2020-03-16 by the reprex package (v0.3.0)
Yes. Patchwork makes some assumptions about facets in order to be able to align them properly. I have yet to formalise a description of these assumptions to guide facet extension developers but this should of course be done
Hi Thomas,
I think I managed to fix the issue of patchwork compatibility with nested facets at my end. The main issue was the way I stored strips in the gtable object. The following are things I ran into that might make it easier to describe the assumptions.
- Strips should be named
strip-t*,strip-b*,strip-l*orstrip-r*. - Vertical strips are assumed to be 1 cell wide.
- Vertical strips can be multiple cells tall.
- Horizontal strips are assumed to be 1 cell tall.
- Horizontal strips can be multiple cells wide.
Best wishes, Teun
+1 here for facet_nested and patchwork
@brunomioto Can you post a reprex here for the facet nested issue? I doubt it a patchwork issue.