[Matplotlib-users] autoscale y axis in different [x1,x2] range
Eric Firing
efiring at hawaii.edu
Thu Nov 30 18:28:07 EST 2017
On 2017/11/29 11:55 PM, jlx wrote:
> hey everyone, I meet a problem about autoscale.
>
> I change the x axis range so that I can see the details of the curve, but y
> axis range is always the same, it does not change automatically to zoom in.
>
> I tried autoscale on and set_autoscale_view, but do not work, could you help
> me about that?
>
> the following are curves at whole x range and [x1,x2] range:
>
> <http://matplotlib.1069221.n5.nabble.com/file/t5114/whole.png>
> <http://matplotlib.1069221.n5.nabble.com/file/t5114/10-20.png>
>
> So how to make the black, red and blue curves fit the subplot window
> automatically?
You will need to write a function to calculate the appropriate y limits
based on your input data and the x limits, and then connect it to the
'xlim_changed' event. Something like this is illustrated here:
http://matplotlib.org/gallery/event_handling/resample.html#sphx-glr-gallery-event-handling-resample-py
Eric
More information about the Matplotlib-users
mailing list