-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Labels
Milestone
Description
When using pyplot, I can use axis('equal') to make the axes have the same scale (a circle is a circle). However, this leaves a hole for the common case of comparing experiment with theory where a square plot is desired (i.e., the axes should have the same limits).
To achieve this, I typically write a function:
def equalAxisLimits(ax):
'''
Make both axes have the same range. Useful for producing square plots.
'''
xlim = ax.get_xlim()
ylim = ax.get_ylim()
minLimit = min(xlim[0], ylim[0])
maxLimit = max(xlim[1], ylim[1])
ax.axis([minLimit, maxLimit] * 2)
Ideally something like this would be built into matplotlib. Maybe it already is and I missed it? If not, it would be a handy addition. Beats having everyone copy/paste the wheel - I must have seen it implemented over a hundred times.
Reactions are currently unavailable