✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

How to set up xrangeslider for all subplots

hi all,
I set up multiple subplots using add_traces with each a candlestick trace. However, the update_layout for xaxis_rangeslider_visible seems to be working for the first subplot only. any idea? much appreciated.

fig.add_traces(tracelist, rows=[1,1,2,2], cols=[1,2,1,2], )
fig.update_layout( title_font_size=30, showlegend=False,

Hi @michaellp, welcome to the community!

When you update the layout, the argument xaxis refers only to the first subplot x-axis. To refer to the other subplots you have to point to the respective axes for each subplot with something like xaxis2_rangeslider_visible=False, xaxis3_rangeslider_visible=False, etc.

There is probably a more elegant solution though

hope it helps


1 Like

Only posting because I searched for this forever and couldn’t find anything, but here is the more elegant solution:

  1. Use fig.for_each_xaxis(fn) to iterate through all xaxis of subplots (alternative use for_each_trace if you don’t want to set all rangesliders to not visible)

  2. Where fn takes a single plotly.graph_objects.layout.XAxisas argument

So it should look like

def xdel(xax):
    xax.rangeslider = {"visible":False}


Thanks @Alexboiboi for helping me find this solution.

As I explained in RangeSlider Overlaps with Subplots.

To remove the first slider for the fig.


Any subsequent calls for with fig.update_layout(xaxis_rangeslider_visible=False) will have no effect.
To remove the rangeslider for each subsequent trace, you have to refer to them by their row and col.

fig.update_xaxes(rangeslider= {'visible':False}, row=2, col=1)
fig.update_xaxes(rangeslider= {'visible':False}, row=3, col=1)