-
I have an xarray Dataset called dens that I would like to plot. This is the Dataset:
I am using the command
to plot it and it's working, but since I would like to have the coastline also drawn on the plot, I am also trying to use
ut when I run all of the commands, and then run plt.show() ,the contour plot disappears, and all that it shows me is the coastline. How could I fix this to get a contour plot + the coastline plot in the same figure? Sorry if this is a silly question, but i'm pretty new to python |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Plotting with basemap and xarray is already discussed here.
The above code should work. I use cartopy for features like coastlines and borders. Below is the working code snippet for you to try with your dataset. ''' ds = xr.open_dataset('filename.nc') ax.add_feature(cf.COASTLINE.with_scale("50m"), lw=0.5) ds.density[-1,:,:].plot.contourf() |
Beta Was this translation helpful? Give feedback.
Plotting with basemap and xarray is already discussed here.
The above code should work. I use cartopy for features like coastlines and borders. Below is the working code snippet for you to try with your dataset.
'''
import xarray as xr
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cf
ds = xr.open_dataset('filename.nc')
fig = plt.figure(figsize=(8,8))
crs=ccrs.P…