How to apply ax.margins to current axes limits?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to apply ax.margins to current axes limits?

Jack Yu

Is there a way to use ax.margins to adjust the axes limits, after the axes limits have already been adjusted using ax.set_ylim? It appears that ax.margins has effect only if ax.set_ylim has not been used.

This notebook
http://nbviewer.jupyter.org/github/qap/python_examples/blob/matplotlib/matplotlib/matplotlib_axmargins.ipynb

describes a situation in which this need may arise.

Note: the y-axis is just an example, the same also applies to the x-axis (ax.set_xlim).


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to apply ax.margins to current axes limits?

tcaswell
The margins are only used when Matplotlib auto-selects the limits for you.  Once you have used `set_xlim` or `set_ylim` we take those as explicit user-intent and will not automatically change the limits again.

Tom

On Sat, Jan 28, 2017 at 11:00 AM Jack Yu <[hidden email]> wrote:

Is there a way to use ax.margins to adjust the axes limits, after the axes limits have already been adjusted using ax.set_ylim? It appears that ax.margins has effect only if ax.set_ylim has not been used.

This notebook
http://nbviewer.jupyter.org/github/qap/python_examples/blob/matplotlib/matplotlib/matplotlib_axmargins.ipynb

describes a situation in which this need may arise.

Note: the y-axis is just an example, the same also applies to the x-axis (ax.set_xlim).

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Loading...