You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""NCL_stream_1.py===============This script illustrates the following concepts: - Drawing a black-and-white streamline plot over a mapSee following URLs to see the reproduced NCL plot & script: - Original NCL script: https://www.ncl.ucar.edu/Applications/Scripts/stream_1.ncl - Original NCL plot: https://www.ncl.ucar.edu/Applications/Images/stream_1_lg.pngNote: The streamlines generated in this plot approximate, but do not exactlymatch those generated by the NCL version. This is primarily because the seed point generation algorithm used by NCL is opaque."""################################################################################# Import packages:importnumpyasnpimportxarrayasxrimportcartopy.crsasccrsimportmatplotlib.pyplotaspltimportcartopy.featureascfeatureimportgeocat.datafilesasgdffromgeocat.vizimportutilasgvutil################################################################################# Read in data:# Open a netCDF data file using xarray default engine and load the data into xarraysds=xr.open_dataset(gdf.get('netcdf_files/uvt.nc'))
# Extract a 2D horizontal slice from the first time step of the 3D U and V variables at the bottom levelU=ds.U.isel(time=0, lev=0)
V=ds.V.isel(time=0, lev=0)
################################################################################# Plot:# Generate figure (set its size (width, height) in inches)plt.figure(figsize=(16, 8))
# Generate axes using Cartopy projectionprojection=ccrs.PlateCarree()
ax=plt.axes(projection=projection)
# Use global mapax.set_global()
# Stream-plot the data# There is no Xarray streamplot function, yet. So need to call matplotlib.streamplot directly. Not sure why, but can't# pass xarray.DataArray objects directly: fetch NumPy arrays via 'data' attribute'ax.streamplot(U.lon.data,
U.lat.data,
U.data,
V.data,
linewidth=1,
density=4,
color='black',
zorder=1)
# Show the plotplt.tight_layout()
plt.show()
Actual outcome
Traceback (most recent call last):
File "/opt/anaconda3/envs/geocat-examples/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3417, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-32ee43073f80>", line 1, in <module>
runfile('/Users/anissaz/Desktop/GeoCAT/GeoCAT-examples/Plots/Streamlines/NCL_stream_1.py', wdir='/Users/anissaz/Desktop/GeoCAT/GeoCAT-examples/Plots/Streamlines')
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/anissaz/Desktop/GeoCAT/GeoCAT-examples/Plots/Streamlines/NCL_stream_1.py", line 64, in <module>
plt.show()
File "/opt/anaconda3/envs/geocat-examples/lib/python3.7/site-packages/matplotlib/pyplot.py", line 337, in show
return _backend_mod.show(*args, **kwargs)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm_matplotlib_backend/backend_interagg.py", line 29, in __call__
manager.show(**kwargs)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm_matplotlib_backend/backend_interagg.py", line 113, in show
self.canvas.show()
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm_matplotlib_backend/backend_interagg.py", line 68, in show
self.figure.tight_layout()
File "/opt/anaconda3/envs/geocat-examples/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper
return func(*inner_args, **inner_kwargs)
File "/opt/anaconda3/envs/geocat-examples/lib/python3.7/site-packages/matplotlib/figure.py", line 2615, in tight_layout
pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
File "/opt/anaconda3/envs/geocat-examples/lib/python3.7/site-packages/matplotlib/tight_layout.py", line 308, in get_tight_layout_figure
pad=pad, h_pad=h_pad, w_pad=w_pad)
File "/opt/anaconda3/envs/geocat-examples/lib/python3.7/site-packages/matplotlib/tight_layout.py", line 84, in auto_adjust_subplotpars
bb += [ax.get_tightbbox(renderer, for_layout_only=True)]
File "/opt/anaconda3/envs/geocat-examples/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 4203, in get_tightbbox
bbox = a.get_tightbbox(renderer)
File "/opt/anaconda3/envs/geocat-examples/lib/python3.7/site-packages/matplotlib/artist.py", line 286, in get_tightbbox
bbox = Bbox.intersection(bbox, clip_path.get_extents())
File "/opt/anaconda3/envs/geocat-examples/lib/python3.7/site-packages/matplotlib/path.py", line 603, in get_extents
return Bbox([xys.min(axis=0), xys.max(axis=0)])
File "/opt/anaconda3/envs/geocat-examples/lib/python3.7/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
Here is a link to one of our current unmerged PRs with sphinx documentation generation failures for more than just this example, if that is helpful.
Expected outcome
Used to produce the following image:
Previously working example documented with readthedocs here
Version 3.3.0 was the last version that did not experience this.
Bug report
Bug summary
Previously working example documentation code using tight_layout() and constrained_layout now produces errors.
Code for reproduction
One of the failing codes (github link):
Actual outcome
Here is a link to one of our current unmerged PRs with sphinx documentation generation failures for more than just this example, if that is helpful.
Expected outcome

Used to produce the following image:
Previously working example documented with readthedocs here
Version 3.3.0 was the last version that did not experience this.
Matplotlib version
print(matplotlib.get_backend())
): module://backend_interaggInstalled matplotlib from conda environment
The text was updated successfully, but these errors were encountered: