Reputation: 1127
I have a plotly graph with several traces. Some of them I don't want to appear in the legend. How do I do this?
Upvotes: 12
Views: 12086
Reputation: 2753
You need to set showlegend = F
in your trace:
CODE
library(plotly)
plt <- plot_ly(as.data.frame(mtcars)) %>%
add_markers(x = ~wt, y = ~mpg, name = 'Fuel Eff.', type = 'scatter') %>%
add_markers(x = ~wt, y = ~hp, name = 'Power to wt. ratio', type = 'scatter',
showlegend = F) %>%
layout(
showlegend = T,
legend = list(orientation = 'h')
)
Output
Upvotes: 18