Skip to content

Commit 922bea4

Browse files
committed
Quick and dirty fix proposal for tidyverse/ggplot2#5428
1 parent e720a51 commit 922bea4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

R/ggplotly.R

+9-1
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,15 @@ scales_add_missing <- function(plot, aesthetics) {
15121512
# towards ggproto methods attached to `plot$guides`
15131513
# -------------------------------------------------------------------------
15141514
get_gdefs_ggproto <- function(scales, theme, plot, layers) {
1515-
guides <- plot$guides$setup(scales)
1515+
1516+
# Proposed change to accomodate
1517+
# https://github.com/tidyverse/ggplot2/pull/5428
1518+
# Ensure a 1:1 mapping between aesthetics and scales
1519+
aesthetics <- lapply(scales, `[[`, "aesthetics")
1520+
scales <- rep.int(scales, lengths(aesthetics))
1521+
aesthetics <- unlist(aesthetics, recursive = FALSE, use.names = FALSE)
1522+
1523+
guides <- plot$guides$setup(scales, aesthetics = aesthetics)
15161524
guides$train(scales, theme$legend.direction, plot$labels)
15171525
if (length(guides$guides) > 0) {
15181526
guides$merge()

0 commit comments

Comments
 (0)