Closed
Description
Guides are no longer named after Coord::train_panel_guides()
is executed. This occurs in Layout::setup_panel_guides()
which constructs the guides if they are missing and names them via Coord::setup_panel_guides()
.
The issue appears to be the addition of a line of code within Coord::train_panel_guides()
with the intersect()
function (copied here). intersect
strips the names of the input character vector.
The names of the guides help to link them with their associated scales, and the breaking of this link breaks code in an extension package. This change also undoes the preceding line, which sets the names.
aesthetics <- c("x", "y", "x.sec", "y.sec")
names(aesthetics) <- aesthetics
# If the panel_params doesn't contain the scale, there's no guide for the aesthetic
aesthetics <- intersect(aesthetics, names(panel_params$guides))
Reprex
library(ggplot2)
gg <- ggplot()
data <- ggplot_build(gg)
# Excerpt from ggplot_gtable.ggplot_built
plot <- data$plot
layout <- data$layout
data <- data$data
layout$setup_panel_guides(plot$guides, plot$layers, plot$mapping)
# Line showing change in outcome
names(layout$panel_params[[1]]$guides)
Expected output (and output prior to #3972 / commit 10eba36):
[1] "x" "y" "x.sec" "y.sec"
Current output:
NULL
Metadata
Metadata
Assignees
Labels
No labels