I'm just trying to set up a code to plot a skewT graph, but the code falls over immediately on the very first call to set up the graph incidence
import matplotlib.pyplot as plt
from metpy.plots import SkewT
skew=SkewT()
gives me the following traceback, is this a bug in the latest metpy version? (I just upgraded)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/metpy/plots/skewt.py", line 316, in __init__
self.ax = fig.add_subplot(*subplot, projection='skewx', rotation=rotation)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/figure.py", line 772, in add_subplot
ax = subplot_class_factory(projection_class)(self, *args, **pkw)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axes/_subplots.py", line 34, in __init__
self._axes_class.__init__(self, fig, [0, 0, 1, 1], **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/metpy/plots/skewt.py", line 195, in __init__
super().__init__(*args, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/_api/deprecation.py", line 456, in wrapper
return func(*args, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axes/_base.py", line 632, in __init__
self.cla()
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axes/_base.py", line 1249, in cla
self.grid(False) # Disable grid on init to use rcParameter
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/_api/deprecation.py", line 299, in wrapper
return func(*args, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axes/_base.py", line 3226, in grid
self.xaxis.grid(visible, which=which, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/_api/deprecation.py", line 299, in wrapper
return func(*args, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axis.py", line 1434, in grid
self.set_tick_params(which='major', **gridkw)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axis.py", line 873, in set_tick_params
for tick in self.majorTicks:
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axis.py", line 592, in __get__
tick = instance._get_tick(major=True)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/metpy/plots/skewt.py", line 134, in _get_tick
return SkewXTick(self.axes, None, label=None, major=major)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axis.py", line 415, in __init__
super().__init__(*args, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axis.py", line 160, in __init__
self.gridline = mlines.Line2D(
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/lines.py", line 393, in __init__
self.update(kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/artist.py", line 1064, in update
raise AttributeError(f"{type(self).__name__!r} object "
AttributeError: 'Line2D' object has no property ''
I'm on
Python 3.9.9 (main, Nov 21 2021, 03:23:42)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
and using
metpy.__version__
'1.1.0'
CodePudding user response:
This is caused by the recently released matplotlib 3.5. We are planning on releasing a fix for this with MetPy 1.2, scheduled to be released shortly.
In the meanwhile as a workaround, you'll need to downgrade to matplotlib 3.4.