plotly range slider without showing line in small

Question:

I want to use Plotly to generate a line chart with a range slider. the range slider shows the displayed line again. this code is just an example. in my case, I have a lot of subplots and everything is shown twice. is it possible to show nothing or only the date in the range slider?

import plotly.express as px
import yfinance as yf
yf.pdr_override()



df = yf.download(tickers='aapl' ,period='1d',interval='1m')

fig = px.line(df, x = df.index, y = 'Close',
              title='Apple Stock Price')

fig.update_layout(
    xaxis=dict(
        rangeselector=dict(
            buttons=list([
                dict(count=1,
                     label="1m",
                     step="month",
                     stepmode="backward"),
                dict(step="all")
            ])
        ),
        rangeslider=dict(
            visible=True
        ),
        type="date"
    )
)

fig.show()
Asked By: Alex

||

Answers:

Looking through the rangeslider documentation, there aren’t any arguments that can directly impact the rangeslider line because I believe that line will have all of the same properties as the line in the figure (including color, visibility, thickness).

The best workaround I can come up with is to change the background color of the rangeslider to be the same color as the line (and this only works if all traces in the figure are the same color). I would probably also make the rangeslider have a relatively smaller thickness so it’s less obtrusive, but that’s a matter of personal taste.

Here is an example:

fig.update_layout(
    xaxis=dict(
        rangeselector=dict(
            buttons=list([
                dict(count=1,
                     label="1m",
                     step="month",
                     stepmode="backward"),
                dict(step="all")
            ])
        ),
        rangeslider=dict(
            visible=True,
            bgcolor="#636EFA",
            thickness=0.05
        ),
        type="date"
    )
)

fig.show()

enter image description here

Answered By: Derek O