Is there an easy and reliable way to determine the current aspect ratio of an axes when its aspect is set to \'auto\'?
The obvious thing to
The best thing I can find is this:
def get_aspect(ax=None):
if ax is None:
ax = plt.gca()
fig = ax.figure
ll, ur = ax.get_position() * fig.get_size_inches()
width, height = ur - ll
axes_ratio = height / width
aspect = axes_ratio / ax.get_data_ratio()
return aspect
But it's surprisingly complicated, and I'm not sure if it is reliable under transforms, etc, as I know nothing about the bbox and transform objects.