Skip to content

Conversation

@jonasvdd
Copy link
Member

@jonasvdd jonasvdd commented Mar 6, 2025

Related PR #336
Related issue: #335 (which contains a thorough explanation)

Example to try:

import numpy as np
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from plotly_resampler import FigureResampler


time = 1000
N = 4001  # number of points in the subplot exceeds default_n_shown_samples
x = 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=2, cols=1), verbose=True)

fig.add_trace(go.Scattergl(), hf_x=x, hf_y=y, row=1, col=1)

fig.add_trace(go.Scattergl(), hf_x=x, hf_y=-y, row=2, col=1)

fig.update_xaxes(
    range=[0, np.ceil(x[-1])],  # set the x range of the subplot
    row=1,
    col=1,
)

fig.update_xaxes(
    range=[0, np.ceil(x[-1])],  # set the x range of the subplot
    row=2,
    col=1,
)
fig.show_dash(config={"scrollZoom": True})

@jonasvdd jonasvdd self-assigned this Mar 6, 2025
@jonasvdd jonasvdd requested a review from jvdd March 6, 2025 10:05
@jonasvdd jonasvdd added the bug Something isn't working label Mar 6, 2025
@jonasvdd jonasvdd changed the title Pr/yzhaoinuw/336 Fix: Add xaxis.range[0]/[1] If Not Exist Mar 6, 2025
Copy link
Member

@jvdd jvdd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jonasvdd jonasvdd merged commit d6373f4 into predict-idlab:main Mar 6, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants