Unidata / MetPy

MetPy is a collection of tools in Python for reading, visualizing and performing calculations with weather data.
https://unidata.github.io/MetPy/
BSD 3-Clause "New" or "Revised" License
1.25k stars 415 forks source link

tight_layout() produces less-than-ideal results with SkewT #1438

Open tsupinie opened 4 years ago

tsupinie commented 4 years ago

This is a pretty nit-picky thing, but I'm using a skew-T axes between two other non-skewed axes, and matplotlib's tight_layout() gets a bit confused in this situation. This code:

from metpy.plots import SkewT
import matplotlib.pyplot as plt

fig = plt.figure(facecolor='w', dpi=150)
plt.subplot(131)
SkewT(fig=fig, subplot=132)
plt.subplot(133)

plt.tight_layout()
plt.show() 

produces this image:

download

There's a lot more space between the subplots than I would expect for tight_layout(), and the exact amount of space depends on the x limits on the skew-T axes. Setting plt.xlim(0, 50) looks more reasonable, and plt.xlim(-40, 0) looks less reasonable. As a workaround, I can move the skew-T axes to the right subplot, which produces a more reasonable-looking subplot spacing (but still not quite what I'd expect from non-skewed axes).

I am on Mac OS X 10.14.6, running Python 3.6.7, MetPy v0.12.1, and Matplotlib v3.0.2.

dopplershift commented 4 years ago

Well, thanks for reporting. Any chance you can try this with a more recent version of matplotlib? We fixed some aspect ratio things, but it relies on Matplotlib >= 3.2 (3.3 just dropped).