Skip to content

fig.update_xaxes(range=[start,end]) and fig.update_yaxes(range=[start,end]) is not working #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
muntakim1 opened this issue Sep 15, 2022 · 4 comments · Fixed by #126
Closed
Assignees
Labels
bug Something isn't working

Comments

@muntakim1
Copy link

Here is my code:
I am trying to show only the selected range values using the custom slider.

import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from plotly_resampler import FigureResampler
x = np.arange(2_000)
noisy_sin = (3 + np.sin(x / 200) + np.random.randn(len(x)) / 10) * x / 1_00
fig = FigureResampler(go.Figure())
fig.add_trace(go.Scattergl(name="exp",x=x,y=noisy_sin))
fig.update_layout(xaxis_range=[20,300])
@muntakim1 muntakim1 changed the title fig.update_xaxes(range=[]) is not working. fig.update_xaxes(range=[start,end]) is not working. Sep 15, 2022
@jvdd
Copy link
Member

jvdd commented Sep 15, 2022

Hey!

This is indeed a bug, nice catch 👍
We should provide exactly the same behavior as plotly - which is not the case here.

A quick fix for now is setting autorange to False for the xaxes; fig.update_xaxes(autorange=False) . Does this work for you?

In the meantime I'll try to find a more permanent fix for this bug in the code :)

Cheers,
Jeroen

@jvdd jvdd added the bug Something isn't working label Sep 15, 2022
@jvdd jvdd self-assigned this Sep 15, 2022
@muntakim1
Copy link
Author

Hi, Thanks for the comment. I tried earlier but it wasn't working. probably I use the update_layout, Now it's working. thanks agian.
fig.update_xaxes(autorange=False)

@ilianOptrel
Copy link

I noticed the same issue with scaling the y-axis. Neither of the following options work for me:

  • fig.update_layout(yaxis_range=[-1,1])
  • fig.update(layout_yaxis_range = [-1,1])
  • fig.update_yaxes(range = [-1,1]).
    However, setting autoscale to False in fig.update_yaxes(range = [-1.25,1.25], autorange=False) made it work. See my stackoverflow post for more info.

Cheers,
Ilian

@jvdd
Copy link
Member

jvdd commented Oct 10, 2022

Thx for sharing your issue as well @ilianOptrel!

I have been quite busy last month, but I'll take a closer look at this bug somewhere this week :)

At first sight this bug does not occur when using the FigureWidgetResampler. For example the following code should work fine (in an IPython environment, such as Jupyter);

import numpy as np
import plotly.graph_objects as go
from plotly_resampler import FigureWidgetResampler

x = np.arange(2_000)
noisy_sin = (3 + np.sin(x / 200) + np.random.randn(len(x)) / 10) * x / 1_00

fig = FigureWidgetResampler(default_n_shown_samples=20)
fig.add_trace(go.Scattergl(name="exp",x=x,y=noisy_sin))
fig.update_layout(xaxis_range=[200,300])
fig.update_layout(yaxis_range=[0,30])
fig

@jvdd jvdd changed the title fig.update_xaxes(range=[start,end]) is not working. fig.update_xaxes(range=[start,end]) and fig.update_yaxes(range=[start,end]) is not working Oct 10, 2022
@jvdd jvdd linked a pull request Oct 10, 2022 that will close this issue
5 tasks
@jvdd jvdd closed this as completed in #126 Oct 22, 2022
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
3 participants