set_aspect('equal') for log-log plots

classic Classic list List threaded Threaded
1 message Options
DJP
Reply | Threaded
Open this post in threaded view
|

set_aspect('equal') for log-log plots

DJP
I would like to make a log-log plot where the x and y axes have the same scale.  That is, if a decade is one inch physically on the x axis, I want it to be one inch physically on the y axis.  How do I do this?  I tried set_aspect(‘equal’) but it doesn’t work for logarithmic axes.  This makes sense for semi-log plots but it doesn’t make sense for log-log plots, where it should work (logically).  Is there some other straightforward way to do it?  By the way, it would be nice if it worked when there are shared axes, as in the example below.


import matplotlib.pyplot as plt
import numpy as np

xline = np.array([10, 1500])
yline = np.array([0.1, 15.])

ymin, ymax = 0.0001, 10.
fig, ax = plt.subplots(figsize=(5, 8))

lines = np.array([2., 0.4, 0.08, 0.016, 0.0022])
for m in lines:
    ax.loglog(xline, m*yline, dashes=(5, 2))
ax.set_ylim(ymin, ymax)

scale = 1.0e6
axR = ax.twinx()
axR.set_ylim(ymin*scale, ymax*scale)
axR.loglog([], [])

ax.set_aspect('equal', share=True)  # doesn't do anything

plt.show()

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