Hi everyone, Iβm building a timeseries visualization that uses an x-axis rangeslider. The layout is almost identical to this example from the documentation:
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
fig = go.Figure(go.Scatter(
x = df['Date'],
y = df['mavg']
))
fig.update_xaxes(
rangeslider_visible=True,
tickformatstops = [
dict(dtickrange=[None, 1000], value="%H:%M:%S.%L ms"),
dict(dtickrange=[1000, 60000], value="%H:%M:%S s"),
dict(dtickrange=[60000, 3600000], value="%H:%M m"),
dict(dtickrange=[3600000, 86400000], value="%H:%M h"),
dict(dtickrange=[86400000, 604800000], value="%e. %b d"),
dict(dtickrange=[604800000, "M1"], value="%e. %b w"),
dict(dtickrange=["M1", "M12"], value="%b '%y M"),
dict(dtickrange=["M12", None], value="%Y Y")
]
)
fig.show()
If a custom tickformatstops
isnβt used, the x-axis will switch to truncated timestamps when a smaller unit of time is incremented; for example, in the image below the year is omitted when it is not incremented.
I canβt seem to get that same behaviour working when specifying a set of custom timestamp formats to tickformatstops
. Is there a way to replicate the mixed timestamp formatting behaviour, but with custom timestamp formats?
Thanks in advance for your help!