-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Facet: gain draw_facet_panels method to draw grobs for each panel #6421
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
Changes from 1 commit
f962360
95dbcf4
4a2189b
a8c2a9d
9b8eebf
27fb3da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,10 @@ NULL | |
#' between the layer stack and the foreground defined by the Coord object | ||
#' (usually empty). The default is, as above, to return an empty grob. | ||
#' | ||
#' - `draw_facet_panels`: Draws each panel for the facet. Should return a list | ||
#' of grobs, one for each panel. The output is used by the `draw_panels` | ||
#' method. | ||
#' | ||
#' - `draw_labels`: Given the gtable returned by `draw_panels`, | ||
#' add axis titles to the gtable. The default is to add one title at each side | ||
#' depending on the position and existence of axes. | ||
|
@@ -138,6 +142,34 @@ Facet <- ggproto("Facet", NULL, | |
draw_front = function(data, layout, x_scales, y_scales, theme, params) { | ||
rep(list(zeroGrob()), vec_unique_count(layout$PANEL)) | ||
}, | ||
draw_facet_panels = function(self, panels, layout, x_scales, y_scales, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a better self-descriptive name for this method that we could choose here? Something like |
||
ranges, coord, data, theme, params, ...) { | ||
facet_bg <- self$draw_back( | ||
data, | ||
layout, | ||
x_scales, | ||
y_scales, | ||
theme, | ||
params | ||
) | ||
facet_fg <- self$draw_front( | ||
data, | ||
layout, | ||
x_scales, | ||
y_scales, | ||
theme, | ||
params | ||
) | ||
|
||
# Draw individual panels, then call `$draw_panels()` method to | ||
# assemble into gtable | ||
lapply(seq_along(panels[[1]]), function(i) { | ||
panel <- lapply(panels, `[[`, i) | ||
panel <- c(facet_bg[i], panel, facet_fg[i]) | ||
panel <- coord$draw_panel(panel, ranges[[i]], theme) | ||
ggname(paste("panel", i, sep = "-"), panel) | ||
}) | ||
}, | ||
draw_panels = function(self, panels, layout, x_scales = NULL, y_scales = NULL, | ||
ranges, coord, data = NULL, theme, params) { | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.