m = Basemap(projection='ortho',lat_0=-85,lon_0=-60,resolution='l') lon2, lat2 = np.meshgrid(sst_gradient.lon,sst_gradient.lat) x, y = m(lon2, lat2) z = np.array(sst_gradient.values) fig = plt.figure(figsize=(15,7)) clevs = np.arange(1,10,1.5) cnplot = m.contour(x,y,z,clevs,cmap=plt.cm.RdYlGn) /*error in this line cbar = m.colorbar(cnplot)
MaskError Traceback (most recent call last)
in
----> 1 cnplot = m.contour(x,y,z,clevs,cmap=plt.cm.RdYlGn)
2 cbar = m.colorbar(cnplot)
~/anaconda3/envs/myenv/lib/python3.6/site-packages/mpl_toolkits/basemap/__init__.py in with_transform(self, x, y, data, *args, **kwargs)
544 # convert lat/lon coords to map projection coords.
545 x, y = self(x,y)
--> 546 return plotfunc(self,x,y,data,*args,**kwargs)
547 return with_transform
548
~/anaconda3/envs/myenv/lib/python3.6/site-packages/mpl_toolkits/basemap/__init__.py in contour(self, x, y, data, *args, **kwargs)
3570 # combine with data mask.
3571 mask = np.logical_or(ma.getmaskarray(data),xymask)
-> 3572 data = ma.masked_array(data,mask=mask)
3573 CS = ax.contour(x,y,data,*args,**kwargs)
3574 finally:
~/anaconda3/envs/myenv/lib/python3.6/site-packages/numpy/ma/core.py in __new__(cls, data, mask, dtype, copy, subok, ndmin, fill_value, keep_mask, hard_mask, shrink, order, **options)
2870 msg = "Mask and data not compatible: data size is %i, " + \
2871 "mask size is %i."
-> 2872 raise MaskError(msg % (nd, nm))
2873 copy = True
2874 # Set the mask to the new value
MaskError: Mask and data not compatible: data size is 1, mask size is 2592000.
-------------------------------------------------------------------------------------------------------------------------------
shape of sst_gradient.lon=4320 and sst_gradient.lat=600, length of
sst_gradient.values=1
thanks in advance
m = Basemap(projection='ortho',lat_0=-85,lon_0=-60,resolution='l') lon2, lat2 = np.meshgrid(sst_gradient.lon,sst_gradient.lat) x, y = m(lon2, lat2) z = np.array(sst_gradient.values) fig = plt.figure(figsize=(15,7)) clevs = np.arange(1,10,1.5) cnplot = m.contour(x,y,z,clevs,cmap=plt.cm.RdYlGn) /*error in this line cbar = m.colorbar(cnplot)
MaskError Traceback (most recent call last)