The y-axis is not adjusting to a new scale when I adjust the x-axis range.
How do i add this feature?
The y-axis is not adjusting to a new scale when I adjust the x-axis range.
How do i add this feature?
How are you making this plot? I would copy and paste the Time Series with Range Slider example from the docs. The y-axis adjusts depending on the range of y-values in the current selection.
Do you mind copying and pasting your code here?
fig = px.line(df_combo, x = 'DATE', y = 'DGS10')
fig.update_layout(
title = "10-Year Treasury Constant Maturity Rate",
xaxis_title = "Date",
yaxis_title = "Yield Percent",
)
fig.update_xaxes(
rangeslider_visible = True,
rangeselector = dict(
buttons = list([
dict(count = 1,
step = 'month',
label = '1M',
stepmode = 'backward'),
dict(count = 6,
label = '6M',
step = 'month',
stepmode = 'backward'),
dict(count = 1,
label = 'YTD',
step = 'year',
stepmode = 'todate'),
dict(count = 1,
label = '1Y',
step = 'year',
stepmode = 'backward'),
dict(count = 3,
label = '3Y',
step = 'year',
stepmode = 'backward'),
dict(count = 5,
label = '5Y',
step = 'year',
stepmode = 'backward'),
dict(count = 7,
label = '7Y',
step = 'year',
stepmode = 'backward'),
dict(count = 10,
label = '10Y',
step = 'year',
stepmode = 'backward'),
dict(step= 'all')
])
)
)
fig.update_yaxes(
autorange = True,
fixedrange = False
)
fig.show()
I would like either: (1) range selection for the y-axis OR (2) a y-axis that automatically adjusts when I change the scope of the x-axis.
I am looking to do the same. Did you find a solution for this?
Same here, I’m also looking for that feature. Is it maybe possible to do it via a zoom event handler?
I’m also looking for this and found something similar in the Javascript Plotly but haven’t found it in the python implementation yet. Please update this thread if you ever find an answer though!
Anyone managed to solve that?
thanks
I wasn’t able to solve it in a clean manner at all really… I did a roundabout method with filtering my entire dataset using a couple buttons that dictated 1m, 3m, 6m, 1y, 5y, etc and then just recreated the graph each time someone clicked on one of them. Really handicapped the experience of using Plotly charts for a lot of my time series data though so I’d be curious if @chriddyp has any suggestions? It’s one of those things that I would assume there’s a workaround or an obvious solution that we’re missing hidden somewhere in the docs, but that I just can’t seem to find. Thanks!
I found a solution here: Autorescaling y axis range when range slider used
Adding fixedrange= False
in the yaxis
options fixed the issue for me.