Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Rangeslider disappears when any trace set to visible=FALSE

Hello everyone,

Rangeslider feature disappears in R when you set any of the tracers into visible=FALSE mode. I am including an example below. If you remove the “visible=FALSE” argument from the add_trace everything works perfectly. Any hint on why this is happening?

Thanks in advance!

library(plotly)
library(quantmod)

getSymbols(Symbols = c(“AAPL”, “MSFT”))

ds <- data.frame(Date = index(AAPL), AAPL[,6], MSFT[,6])

plot_ly(ds, x = ~Date, y = ~AAPL.Adjusted, mode = “lines”, type=“scatter”, name = “Apple”) %>%
add_trace(x = ~Date, y = ~MSFT.Adjusted, mode = “lines”, type=“scatter”, name = “Microsoft”, visible=F) %>%
layout(
title = “Stock Prices”,
xaxis = list(
rangeselector = list(
buttons = list(
list(
count = 3,
label = “3 mo”,
step = “month”,
stepmode = “backward”),
list(
count = 6,
label = “6 mo”,
step = “month”,
stepmode = “backward”),
list(
count = 1,
label = “1 yr”,
step = “year”,
stepmode = “backward”),
list(
count = 1,
label = “YTD”,
step = “year”,
stepmode = “todate”),
list(step = “all”))),

  rangeslider = list(type = "date")),

yaxis = list(title = "Price"))
1 Like

Hi,

The same is happening with add_lines.
Was looking for a code error until faced to your post.
Could also mention that if we set, in a button list, visible = TRUE for all hidden plots, a slider appears again by clicking this button.

Have you found any workaround of the original problem?

Thanks, Andrey.

Hello Andrey,

I haven’t found any work around yet. I just set everything to TRUE for the time being and I can later select with the sliders the lines that I want to show. Nevertheless thanks for the reply. If I have any news on the matter I’ll let you know.

Cheers,
Thanos

Hi,
If you are still interested in this, it’s fixed now, i.e. it works with multiple graphs when some of them have visible=False.
plotly 4.7.1

Andrey.