I have some data that I want to get a contour plot from. This is my code (the data is open source):
import xarray as xr
import hvplot.xarray
import cartopy.crs as ccrs
ds = xr.open_dataset('http://geoport.usgs.esipfed.org/thredds/dodsC/bathy/etopo1_bed_g2')
na = ds.topo.sel(lon=slice(-130,-50),lat=slice(15,50)) # North America
na = na.where(na < 0)
na = na.where(na > -1000)
contours = na.hvplot.contour(x='lon', y='lat', levels=5, cmap=['#000000'],
geo=True, crs=ccrs.PlateCarree())
contours
This creates an empty plot with the warning:
WARNING:param.project_path: While projecting a Contours element from a PlateCarree coordinate reference system (crs) to a PlateCarree projection none of the projected paths were contained within the bounds specified by the projection. Ensure you have specified the correct coordinate system for your data.
However, if I plot that same data as a quadmesh, it plots fine and the projection is correct.
na.hvplot.quadmesh(x='lon', y='lat', rasterize=True, geo=True, project=True, cmap='viridis', frame_width=800, crs=ccrs.PlateCarree())
Also, if I add project=True
to the contour plot, I get this error:
File /home/conda/global/d346bceda0a73e0d4a1d000f6e408ff98f97300889e28f2363f683db19a0f74c-20230620-190627-268969-5-hytest-workshop/lib/python3.10/site-packages/holoviews/plotting/bokeh/element.py:903, in ElementPlot._update_ranges(self, element, ranges)
901 if fixed_height:
902 plot.frame_height = height
--> 903 plot.frame_width = int(height/aspect)
904 plot.width, plot.height = None, None
905 elif fixed_width:
ValueError: cannot convert float NaN to integer
Am I doing something wrong on the contours plot or is this a bug?