Closed trevorld closed 2 years ago
A geom_sf()
example taken from one of @coolbutuseless's other packages:
suppressPackageStartupMessages({
library(dplyr)
library(sf)
library(ggplot2)
library(sfheaders)
})
coords <- readr::read_csv(
'x,y,idx
0,0,1
4,0,1
4,4,1
0,4,1
0,0,1
1,1,2
2,1,2
2,2,2
1,2,2
1,1,2
', show_col_types = FALSE)
this_sf <- coords %>%
sfheaders::sf_polygon(x='x', y='y', linestring_id = 'idx')
ggplot(this_sf) +
geom_sf(aes(geometry = geometry), fill = 'lightblue')
Using grid.force()
and grid.ls()
it looks like geom_sf()
(and geom_sf_pattern()
) plots a pathGrob()
object so we theoretically should be able to clip the associated pattern using gridpattern::clippingPathGrob()
:
1) Calculate pathGrob()
2) Calculate bounding box (via grobPoints()
?)
3) Generate pattern using bounding box rectangle as boundary (so raster patterns are scaled appropriately)
4) Clip pattern to pathGrob()
via gridpattern::clippingPathGrob()
5) Ideally if geom only needs polygons (instead of paths) use those directly...
pathGrob()
?
Would be very helpful to have a minimal, clear reproducible example for
{ggpattern}
currently does not support "holes"42 implements #43 which should theoretically make supporting geoms with holes feasible. Having an example to look at/test would make it much easier to add "hole" support for such geoms.