Skip to content

When using ggplotly() there can be duplication of legend items inconsistent with ggplot output #2043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wphampton opened this issue Oct 11, 2021 · 1 comment · Fixed by #2067

Comments

@wphampton
Copy link

Thank you for this fantastic package -- I am amazed how well it works!

When multiple geom_line() or geom_point() entries exist, the ggplotly() output can be different from the ggplot() output. What I've noticed is duplication of legend entries and sometimes ignoring of legend configuration options that ggplot provides.

Seems possibly related to #572 & #2010

df1 <- data.frame(
  "Date" = seq(as.Date("2021-01-01"), as.Date("2021-01-10"), "days"),
  "Series" = c(rep("SeriesA", 10), rep("SeriesB",10)),
  "Values" = rnorm(n = 20),
  "Mean" = 0,
  "V1" = 2,
  "V2" = -2
)

p <- ggplot(df1, aes(x=Date, y=Values, color = Series, linetype = Series, shape = Series)) +
  geom_line(aes(x = Date, y = Mean, color = "Mean", linetype = "Mean")) +
  geom_line(aes(x = Date, y = V1, color = "QC", linetype = "QC")) +
  geom_line(aes(x = Date, y = V2, color = "QC", linetype = "QC")) +
  geom_line() + 
  geom_point() + 
  guides(shape=FALSE, linetype=FALSE)

ggplotly(p)

ggplot() Output

image

ggplotly() Output

image

@moutikabdessabour
Copy link
Contributor

this issue is probably the same as #2007.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants