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

Subplot with shared x-axis and range slider

Hi,

I was wondering if it’s possible to create a plot with 3 subplots arranged vertically (https://plot.ly/python/subplots/) that have a shared x-axis, along with a range slider that controls the x-axis (https://plot.ly/python/range-slider/)?

Any help is appreciated.

Thanks,
Julian

Hi,

  1. If 3 subplots are vertically arranged, they can share the X-axis like this -

           fig = make_subplots(rows=3, cols=1,  shared_xaxes=True )
    
  2. After using a common X-axis, subplots can be added to the figure.

  3. Then range slider can be enabled for the bottom subplot like this -

           fig.update_layout(legend_orientation="h", 
                 xaxis3_rangeslider_visible=True, xaxis3_rangeslider_thickness=0.1 )
    

This range slider will be common and shared by all the subplots.

Cheers