R默认情况下Plotly取消选择跟踪 [英] R Plotly Deselect trace by default
本文介绍了R默认情况下Plotly取消选择跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用R Plotly,并具有以下格式的行:
I am ussing R Plotly and have a line of the form:
add_trace(y = meanRank,
x = DateOnly,
data = timeSeriesDF,
name = "Daily Value",
text = hoverText,
hoverinfo = "text",
showlegend = TRUE)
工作正常.但是,我希望在显示该图时取消选择"此轨迹.因此,用户可以在图例上单击它以显示该行.我似乎找不到显示该参数的参数.
It works fine. However, I want this trace to be "unselected" when the plot is shown. So a user would click it on the legend to show the line. I can't seem to find the parameter to show that.
推荐答案
您可以添加visible = "legendonly"
:
library(plotly)
economics %>%
transform(rate = unemploy / pop) %>%
plot_ly(x = date, y = rate) %>%
loess(rate ~ as.numeric(date), data = .) %>%
broom::augment() %>%
add_trace(y = .fitted, name = "foo", visible = "legendonly")
请参见参考.
这篇关于R默认情况下Plotly取消选择跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文