In the following code, if I uncomment the line with the call to tightlayout, I get a crash in matplotlib. I'll be grateful for any suggestion re. why this is happening.
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
fig= plt.figure(figsize=(12, 7))
ax= fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
ax.stock_img()
# plt.tight_layout()
plt.show()
Here's the traceback:
Traceback (most recent call last): File "test.py", line 6, in plt.tight_layout() File "C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\matplotlib\cbook\deprecation.py", line 451, in wrapper return func(*args, **kwargs) File "C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\matplotlib\pyplot.py", line 1490, in tight_layout gcf().tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect) File "C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\matplotlib\cbook\deprecation.py", line 411, in wrapper return func(*inner_args, **inner_kwargs) File "C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\matplotlib\figure.py", line 2613, in tight_layout kwargs = get_tight_layout_figure( File "C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\matplotlib\tight_layout.py", line 303, in get_tight_layout_figure kwargs = auto_adjust_subplotpars(fig, renderer, File "C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\matplotlib\tight_layout.py", line 84, in auto_adjust_subplotpars bb += [ax.get_tightbbox(renderer, for_layout_only=True)] File "C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\matplotlib\axes_base.py", line 4203, in get_tightbbox bbox = a.get_tightbbox(renderer) File "C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\matplotlib\artist.py", line 286, in get_tightbbox bbox = Bbox.intersection(bbox, clip_path.get_extents()) File "C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\matplotlib\path.py", line 603, in get_extents return Bbox([xys.min(axis=0), xys.max(axis=0)]) File "C:\ProgramData\Anaconda3\envs\py38\lib\site-packages\numpy\core_methods.py", line 43, in _amin return umr_minimum(a, axis, None, out, keepdims, initial, where) ValueError: zero-size array to reduction operation minimum which has no identity
I'm using Python 3.8.5 with matplotlib 3.3.1 and CartoPy 0.18.0.