Skip to content
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

Rescale y-axis for graphs with x-axis rangeslider (Python) #6958

Open
JuanRedondoHernan opened this issue Feb 6, 2018 · 16 comments
Open

Rescale y-axis for graphs with x-axis rangeslider (Python) #6958

JuanRedondoHernan opened this issue Feb 6, 2018 · 16 comments
Labels
feature something new P3 not needed for current cycle

Comments

@JuanRedondoHernan
Copy link

Related with the closed issue #912, I haven't found the functionality on Python Plotly library.
I haven't been able neither to implement something similar as they did in R in the aforementioned issue. I would like to keep everything in Python since I do other parts of analysis and it is intended to be modified by other users. I would appreciate any hit about how to do it.

@cldougl
Copy link
Member

cldougl commented Feb 6, 2018

Hi there,
The range slider is intended to update the range of the control axis, the behaviour does not adjust the overall zoom or rescale the y-axis so this issue would not be considered a bug (please note we ask users to reserve this channel for issues and bugs with Plotly's python api).

As mentioned in the R issue- the range slider functionality is handled in our core graphing library: plotly.js so changes to this feature could be discussed there.

Alternatively, you may be interested in implementing Dash, this is a python tool similar to Shiny for R (mentioned in R issue that you noted above). Specifically you could take a look at the interactive graphing section to see how you can implement events based on zooming on the graph.

Don't forget you can always post questions and get feedback about individual projects that you're working on in our community forum: https://community.plot.ly which is free and open to all users!

@kamal264
Copy link

Hi ,
I am also looking for similar functionality in python-django.
I am working on finance application in django and using plotly to draw stock price.
And want to enable auto range for y-axis else graph is not making any sense in my scenario.
image

After narrowing x-axis range- not able to analyse any price movement

image

@gersteing
Copy link

gersteing commented Oct 5, 2018

I struggled with getting this to work so I developed a code example to share. Example provides automatic updates to the yaxis range when and x range slider is updated. Y axis is set to show only price range of bars that are in the chart with a two tick padding. This worked well for me and I can potentially add any number of trace overlays that I want on top of the chart. Plus, I can run it locally without having to use plotly services. See gitub repo here:

https://github.com/gersteing/DashCandlestickCharting/blob/master/README.md

For whom ever wants to try it out. Runs locally using Flask. Enjoy

@jamescoverdale
Copy link

jamescoverdale commented Jun 21, 2019

I've ran into this same issue using the plotly js library.

I created a simple workaround using the relayout event. Its specific to the ohlc chart type, but can easily modify to work with the other chart types.

Plotly OHLC Rescale yAxis

Codepen Example

Hope it helps someone.

@ernestocr
Copy link

Any update on this request?

@gioxc88
Copy link

gioxc88 commented Apr 15, 2020

please update this
the chart is unusable without auto scaling of y axis

@vinerich
Copy link

vinerich commented May 6, 2020

I'd also like to have this feature in the main plotly.js.
I have several x-range synchronized graphs that display varying data. Without scaling of y axis this is rather not usable depending on the data-range of the graph.

Atm I also use nearly the same workaround as @jamescoverdale to implement this by myself.

@tumkik
Copy link

tumkik commented May 24, 2020

I got some issue similar to this one when create candlestick chart using plotly.
The problem is the rangeslider itself.
To fix the issue, you simply remove the rangeslider.
After that y axis will automaically scalling when you zoom. (however, you cannot use rangeslider anymore, but in my case, drag zoom works just fine for me)

just add below code for removing rangeslider in the 'layout'
xaxis:{'rangeslider': {'visible': False}}

@wuxian08
Copy link

wuxian08 commented Jun 3, 2020

Just to add some more information, I noticed that there was a community discussion (https://community.plotly.com/t/y-axis-autoscaling-with-x-range-sliders/10245) regarding to this and the proposed method (an 'xaxis.range' event registered in layout) seemed outdated.

This would be very appealing in some use cases

@peter-hartmann
Copy link

Setting yaxis fixedrange to false will allow to zooming while having a range slider. It's not autoscaling but it's easy and much better over having no zoom at all.

Hope this helps someone.

Credits: https://stackoverflow.com/a/52816021/10689649

{
    yaxis: {
      fixedrange: false
    }
}

@eightbit
Copy link

Single line:
fig.update_yaxes(fixedrange=False)

@valankar
Copy link

valankar commented Oct 1, 2022

Is there still no way to do this with rangeselector/slider and HTML plots? I do not want to use Dash.

@Thomas-Heniart
Copy link

I am also looking for an easier solution 🙏

@LucaZiegler
Copy link

Please fix that
image

@secsilm
Copy link

secsilm commented Apr 7, 2024

Still no solu?

@ndrezn ndrezn reopened this Apr 11, 2024
@ndrezn ndrezn transferred this issue from plotly/plotly.py Apr 11, 2024
@ndrezn
Copy link
Member

ndrezn commented Apr 11, 2024

Re-opening as this is a valid feature request, but it was in the wrong place! Something we might consider for plotly.js which plotly.py would inherit.

@gvwilson gvwilson self-assigned this Jun 11, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added feature something new P3 not needed for current cycle labels Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 not needed for current cycle
Projects
None yet
Development

No branches or pull requests