Skip to content

Commit e726775

Browse files
committed
don't show duplicated legendgroups
1 parent 8bbb6f5 commit e726775

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

R/ggplotly.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ gg2list <- function(p, width = NULL, height = NULL, mapping = "all", source = "A
240240
tr$hoverinfo <- tr$hoverinfo %||%"text"
241241
tr
242242
})
243+
# show only one legend entry per legendgroup
244+
grps <- sapply(traces, "[[", "legendgroup")
245+
traces <- Map(function(x, y) { x$showlegend <- y; x}, traces, !duplicated(grps))
243246

244247
# ------------------------------------------------------------------------
245248
# axis/facet/margin conversion

0 commit comments

Comments
 (0)