Feature request: non-rectangular panel clipping
teunbrand opened this issue · comments
Currently, turning clip = "on"
has little effect for coord_radial()
with out-of-bounds values. In the example below, I'd like it to be possible to clip points to the pacman-shape and not display any data in the upper quarter of the plot.
library(ggplot2)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
scale_x_continuous(limits = c(3, 6), oob = scales::oob_keep) +
coord_radial(
start = 0.25 * pi, end = 1.75 * pi,
clip = "on"
)
Created on 2024-06-20 with reprex v2.1.0
Clipping currently is a property of the grob added to the gtable, and thus the clipping is enforced by a rectangular gtable cell. While the clipping is setup by the coord, it ultimately under controlled by the facets, e.g. here:
Line 66 in ba0b18a
The coord currently has no option to intervene in the clipping, which would ideally occur before panels are handed off to the Facet$draw_panels()
method. I think the best option will be to move the responsibility of the following piece of code from the Layout
to the Coord
, which can then intervene as it sees fit.
Lines 79 to 96 in ba0b18a