Skip to content

Commit 18e9f32

Browse files
committed
plumbing to get data to coords
1 parent 0f7a69c commit 18e9f32

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

R/layout.R

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -219,26 +219,24 @@ Layout <- ggproto("Layout", NULL,
219219
invisible()
220220
},
221221

222-
setup_panel_guides = function(self, guides, layers) {
223-
224-
# Like in `setup_panel_params`, we only need to setup guides for unique
225-
# combinations of x/y scales.
226-
index <- vec_unique_loc(self$layout$COORD)
227-
order <- vec_match(self$layout$COORD, self$layout$COORD[index])
222+
setup_panel_guides = function(self, guides, layers, data = NULL) {
228223

229224
self$panel_params <- lapply(
230-
self$panel_params[index],
225+
self$panel_params,
231226
self$coord$setup_panel_guides,
232227
guides,
233228
self$coord_params
234229
)
235230

236-
self$panel_params <- lapply(
237-
self$panel_params,
238-
self$coord$train_panel_guides,
239-
layers,
240-
self$coord_params
241-
)[order]
231+
self$panel_params <- Map(
232+
function(params, data) {
233+
self$coord$train_panel_guides(params, layers, self$coord_params, data = data)
234+
},
235+
params = self$panel_params,
236+
data = lapply(levels(self$layout$PANEL), function(i) {
237+
lapply(data, function(x) vec_slice(x, x$PANEL == i))
238+
})
239+
)
242240

243241
invisible()
244242
},

R/plot-build.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ggplot_build.ggplot <- function(plot) {
9898
data <- layout$map_position(data)
9999

100100
# Hand off position guides to layout
101-
layout$setup_panel_guides(plot$guides, plot$layers)
101+
layout$setup_panel_guides(plot$guides, plot$layers, data = data)
102102

103103
# Complete the plot's theme
104104
plot$theme <- plot_theme(plot)

0 commit comments

Comments
 (0)