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!

'slider' is not allowed in 'layout'

I’m trying to animate a 3D surface plot with the slider. And I’m following the Gapminder exmple. In the example it says layout has two different key slider and sliders. However when I try to set figure['layout']['slider'] I get the following error:

plotly.exceptions.PlotlyDictKeyError: 'slider' is not allowed in 'layout'

Path To Error: ['layout']['slider']

So is the example wrong or am I missing something? If I remove the slider dictionary then the figure does have a slider but it doesn’t update the plot when the slider is moved.

Currently the animation plays all the frames when you load the page. I would like it to stay on the first frame and just update when slider value is changed. Is it possible to do that with plotly?

I can paste the code if that’ll help but it creates the slider in the exact same manner as the example does.

Any help is much appreciated.

@lordlycastle Yes you are right, the dict layout has no key, slider. It is sliders.
Here is a simpler example for starting working with animations and sliders:
http://nbviewer.jupyter.org/gist/empet/365cf202391bf7a58021388fadd52004

1 Like

Thanks! That got it to work.

A follow up question, now I’m trying to have multiple subplots that I want to update with the slider. I got it to work work by adding the data for second scene in the each frame dict. However, I have to remove the traces key from that dict. So my question is where can I find more information on what that is? How would you find out what it does if you were in my place? I don’t want a straight answer, I want to know how to find it out myself. The reference documentation doesn’t have any info on that.

Cheers

I’m sorry, but I cannot understand your question. Could you be more precise, please?

What is the traces key in frame dict for?

Where is the documentation for it? I can’t find it.

@lordlycastle For an animation you define data as a list of traces, frames and layout.
The traces in data represent the starting plot of the animation, while the frames define the updates of data.
The key traces in a frame points out the indices of traces in data updated by that frame.
Example:

traces=[0]#the first trace in data is updated
traces=[0,1]#the first two traces in data are updated
1 Like

Thanks! Where did you find out what it does? Where’s the documentation? I don’t want to create a new question every time I encounter a new key.

@lordlycastle It seems that there is no reference in https://plot.ly/python/reference to frame attributes. Usually when I experiment a new type of plot/trace I inspect its attributes on https://github.com/plotly/plotly.js. In this case I read the file: https://github.com/plotly/plotly.js/blob/6ebf221f16b7dde558fa8e17d78321e6e3cf6be3/src/plots/frame_attributes.js.