Home > OS >  The x and y axis scaling in Contour plot
The x and y axis scaling in Contour plot

Time:07-08

When I make a contour plot with Python, I have been using a set_aspect function. Because this allows me to avoid image/contour-lines distortion caused by changing both axis.
: for example, ax1.set_aspect('equal', 'box-forced')

But, I just found that the option 'box-forced' is not valid in Python3.

So my question is, is there any alternative of the 'box-forced' option in Python3? I want exactly the same effect as the ax1.set_aspect('equal', 'box-forced') in Python2.
Thanks!

CodePudding user response:

I just found that there is a function plt.axis('scaled'). It seems that this does what I wanted in a recent version (3.7) of Python3.

CodePudding user response:

You can try this one from the official documentation that I found in as my first recommended page:

https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_aspect.html

I'm not sure what you're trying to accomplish here exactly, but you could try the following: ax1.set_aspect(aspect='equal', adjustable='box')

You could also check the following link which is for the set_adjustable method: https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_anchor.html#matplotlib.axes.Axes.set_anchor

Hope this helps. Good luck!

  • Related