Skip to content
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

Issue with showlegend for add_lines #1509

Open
hlendway opened this issue Sep 23, 2019 · 0 comments
Open

Issue with showlegend for add_lines #1509

hlendway opened this issue Sep 23, 2019 · 0 comments

Comments

@hlendway
Copy link

In the second example on this page, Scatterplot with Loess Smoother, add_lines has the attribute showlegend= TRUE and add markers has showlegend=FALSE, and in layout, legend = list(x = 0.80, y = 0.90), yet no legend appears. I would expect a line for the add_lines to show in the plot. I'm wondering if there's an issue? I'm struggling with something similar on a project of my own where I cannot get the legend to show for just one add_lines call.

library(plotly)
p <- plot_ly(mtcars, x = ~disp, color = I("black")) %>%
  add_markers(y = ~mpg, text = rownames(mtcars), showlegend = FALSE) %>%
  add_lines(y = ~fitted(loess(mpg ~ disp)),
            line = list(color = '#07A4B5'),
            name = "Loess Smoother", showlegend = TRUE) %>%
  layout(xaxis = list(title = 'Displacement (cu.in.)'),
         yaxis = list(title = 'Miles/(US) gallon'),
         legend = list(x = 0.80, y = 0.90))
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

No branches or pull requests

1 participant