[英]How can I hide a trace in a legend in R plotly
I have a plotly graph with several traces.我有一个带有几条痕迹的 plotly 图。 Some of them I don't want to appear in the legend.其中一些我不想出现在传说中。 How do I do this?我该怎么做呢?
You need to set showlegend = F
in your trace:您需要在跟踪中设置showlegend = F
:
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 Output
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.