You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a FigureResampler, if the x range of a subplot is set and if the number of points in the subplot exceeds default_n_shown_samples, then clicking Reset Axes after zooming in on the subplot does not reset the trace. It still shows the trace in the zoomed-in view while the x range of the subplot is reset. The user needs to pan or zoom in or out on the subplot again to reset the trace.
Reproducing The Bug 🔍
Minimal code to reproduce the bug.
importnumpyasnpimportplotly.graph_objectsasgofromplotly.subplotsimportmake_subplotsfromplotly_resamplerimportFigureResamplertime=1000N=4001# number of points in the subplot exceeds default_n_shown_samplesx=np.linspace(0.0, time, N, endpoint=False)
y=np.cos(1/2*np.pi+2/50*np.pi*x)
fig=FigureResampler(
make_subplots(
rows=1,
cols=1,
),
default_n_shown_samples=4000,
)
fig.add_trace(
go.Scattergl(
line=dict(width=1),
marker=dict(size=2, color="blue"),
showlegend=False,
mode="lines+markers",
),
hf_x=x,
hf_y=y,
row=1,
col=1,
)
fig.update_xaxes(
range=[0, np.ceil(x[-1])], # set the x range of the subplotrow=1,
col=1,
)
fig.show_dash(config={"scrollZoom": True})
Expected Behavior 🔧
When clicking Reset Axes after zooming in, the trace should be reset along with the x-axis.
Screenshots 📸
plotly_bug_demo.mp4
Environment Information
OS: Windows 11
Python environment:
Python version: 3.12.8
plotly-resampler environment: Web Dash App, Chrome
plotly-resampler version: 0.10.0
Possible Cause
I noticed that in the situation described above, after clicking Reset Axes, relayoutdata only has xaxis.range, but not xaxis.range[0] and xaxis.range[1]. This seemed to be the cause of the bug because in the function _construct_update_data, it explicitly matches the start and the end in thr format of xaxis\d*.range\[0] and xaxis\d*.range\[1], respectively, in order to update the trace.
The text was updated successfully, but these errors were encountered:
Bug Description 🖍️
In a
FigureResampler
, if the x range of a subplot is set and if the number of points in the subplot exceedsdefault_n_shown_samples
, then clicking Reset Axes after zooming in on the subplot does not reset the trace. It still shows the trace in the zoomed-in view while the x range of the subplot is reset. The user needs to pan or zoom in or out on the subplot again to reset the trace.Reproducing The Bug 🔍
Minimal code to reproduce the bug.
Expected Behavior 🔧
When clicking Reset Axes after zooming in, the trace should be reset along with the x-axis.
Screenshots 📸
plotly_bug_demo.mp4
Environment Information
Possible Cause
I noticed that in the situation described above, after clicking Reset Axes,
relayoutdata
only hasxaxis.range
, but notxaxis.range[0]
andxaxis.range[1]
. This seemed to be the cause of the bug because in the function_construct_update_data
, it explicitly matches the start and the end in thr format ofxaxis\d*.range\[0]
andxaxis\d*.range\[1]
, respectively, in order to update the trace.The text was updated successfully, but these errors were encountered: