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.
You could add 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")
See the reference.
you can use the attribute 'visible = legendonly' to other add_
functions such as:
add_lines(x = as.Date(x()$ds),
y = round(y()$total),
name = 'Inventory Total',
visible = 'legendonly')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With