Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬Register for the Oct 27 webinar.

Autorescaling y axis range when range slider used

Hi,

I am aware that this has already been asked a couple of times and was wondering what is the latest update on it.

Is there a way to automatically rescale the displayed range of the y axis combined with the use of a range slider in the x-axis? If yes how can we achieve that?

Thanks

Hello there,

It is possible now to set the yaxis to auto-scale, Try:

yaxis=dict(
       autorange = True,
       fixedrange= False
   )
1 Like

For more info, please refer to this documentation: https://plot.ly/python/reference/#layout-yaxis-autorange
and the PR: https://github.com/plotly/plotly.js/pull/2364

I tried it but nothing rescales on the y-axis. The code I used was taken from this code. The only change was in the layout which can be found below:

layout = {
  "margin": {
    "r": 10, 
    "t": 25, 
    "b": 40, 
    "l": 60
  }, 
  "title": "Stock Prices", 
  "xaxis": {
    "domain": [0, 1], 
    "rangeselector": {"buttons": [
        {
          "count": 3, 
          "label": "3 mo", 
          "step": "month", 
          "stepmode": "backward"
        }, 
        {
          "count": 6, 
          "label": "6 mo", 
          "step": "month", 
          "stepmode": "backward"
        }, 
        {
          "count": 1, 
          "label": "1 yr", 
          "step": "year", 
          "stepmode": "backward"
        }, 
        {
          "count": 1, 
          "label": "YTD", 
          "step": "year", 
          "stepmode": "todate"
        }, 
        {"step": "all"}
      ]}, 
    "title": "Date",
    "rangeslider":{"visible":True}
    
  }, 
  "yaxis": {
    "domain": [0, 1], 
    "title": "Price",
    "autorange": True,
    "fixedrange":False
  }
}
fig = Figure(data=data, layout=layout)
plot_url = py.plot(fig)

And here is an example that illustrates the fact that y-axis won’t rescale.

As you can see the range on the y-axis is verry tight for my selected window on the x-axis, between 20 and 40 but the displayed range is 0-120 (or 140).

Am I missing something?

1 Like

Auto-ranging based on the data bounds is another feature we are currently working on. Please follow #1876