Is it possible to remove the grey boundary lines around the in following map? I am trying to plotting a netcdf using matplotlib
.
from netCDF4 import Dataset # clarify use of Dataset
import matplotlib.pylab as plt
fnc = Dataset(ncfile, 'r')
lat = fnc.variables['latitude'][:]
lon = fnc.variables['longitude'][:]
level = fnc.variables['level'][:]
mydata = fnc.variables['Data'][0, 0, :, :]
plt.figure(figsize = (8, 4))
imgplot = plt.imshow(mydata, cmap = 'YlGn')
plt.colorbar()
plt.show
Edit: I think the grey values are a result of missing values/no data.
Those gray boundaries are an interpolation artifact from imshow
. To get rid of them, do:
imgplot = plt.imshow(mydata, cmap = 'YlGn', interpolation='none')
Or plot through Basemap
and control drawing explicitly, as in this example .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.