[英]R Plotly Deselect trace by default
I am ussing R Plotly and have a line of the form: 我正在使用R Plotly并且有一行表格:
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. 我似乎找不到要显示的参数。
You could add visible = "legendonly"
: 你可以添加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")
you can use the attribute 'visible = legendonly' to other add_
functions such as: 您可以将属性'visible = legendonly'用于其他add_
函数,例如:
add_lines(x = as.Date(x()$ds),
y = round(y()$total),
name = 'Inventory Total',
visible = 'legendonly')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.