Black Lives Matter. Please consider donating to Black Girls Code today.

Combining sliders and dropdown menus

Dear everyone,

I have just started with plot.ly, and I am having some troubles combing sliders and menus to enhance interactivity of my plots.

My situation is the following:

I have to hdf5 files opened via h5py, Fa and Fb, which have several datasets that I want to plot jointly to compare one to the other.

Each dataset is a (Nt,Ne) array of data, and I used sliders to plot each (1,Ne) array as a different plot, using the slider to control which of the plots I want to see.

The problem is that, for me to do this, I have to first fix the dataset I am reading from the h5py, and I really wanted the option to change both the dataset and/or the file I am opening via a drop-down menu.

Besides that, I wanted, if possible, the option to turn on and off which of the files is being shown.

Is any of that possible in plotly?

The way I am doing it is via sliders, and both sliders and dropdown menus require you to set the ‘visible’ variables directly, and I haven’t found a way for them to conditionally change the values they need to show depending on the values of the other, which is what I wanted to do.

Thanks in advance

Hi @hydroguy,

The scenario you’re describing is a bit beyond the capabilities of the built-in sliders/dropdowns.

Are you working in the JupyterNotebook? If so, you could accomplish this using the plotly.py version 3 FigureWidget along with ipywidgets sliders and dropdowns. For an example of a notebook of doing something somewhat similar, see here.

If you’re not working in the notebook, your other option would be to use Dash.

Hope that helps!
-Jon