Skip to content

Commit cc41d21

Browse files
committed
Close #2043: respect guide(aes = 'none') when constructing legend entries
1 parent 50acd97 commit cc41d21

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

R/layers2traces.R

+6-2
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ layers2traces <- function(data, prestats_data, layout, p) {
102102
}
103103
# now to the actual layer -> trace conversion
104104
trace.list <- list()
105+
aes_no_guide <- names(vapply(p$guides, identical, logical(1), "none"))
105106
for (i in seq_along(datz)) {
106107
d <- datz[[i]]
107108
# variables that produce multiple traces and deserve their own legend entries
108-
split_legend <- paste0(names(discreteScales), "_plotlyDomain")
109+
split_legend <- paste0(
110+
setdiff(names(discreteScales), aes_no_guide),
111+
"_plotlyDomain"
112+
)
109113
# add variable that produce multiple traces, but do _not_ deserve entries
110-
split_by <- c(split_legend, "PANEL", "frame", split_on(d))
114+
split_by <- c(split_legend, aes_no_guide, "PANEL", "frame", split_on(d))
111115
# ensure the factor level orders (which determines traces order)
112116
# matches the order of the domain values
113117
split_vars <- intersect(split_by, names(d))

0 commit comments

Comments
 (0)