matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
779 stars 392 forks source link

Cannot normalize pcolormesh colors #468

Closed ricitron closed 5 years ago

ricitron commented 5 years ago

I cannot normalize the colors on a pcolormesh plot.

For example, I can usually normalize a colormap: plt.imshow(data,vmin=-4,vmax=4,cmap=plt.cmap.jet)

However, when using the pcolormesh basemap plotting feature, I cannot normalize the data: m1.pcolormesh(lons,lats,data,shading='flat',cmap=plt.cm.jet,vmin=-4,vmax=4,latlon=True,rasterized=True)

The data simply remains normalized to the max and min value of the data. I've tried using mcolors.Normailze and setting the norm parameter in pcolormesh, and also tried changing the clim values, but nothing works. No matter what when plotting pcolormesh on a basemap I cannot change the normalization of the colormap.

WeatherGod commented 5 years ago

I doubt this is a basemap issue. Basemap just passes keyword arguments down to the regular pcolormesh method, only first taking care of transforming coordinates. I bet the "shading='flat'" argument is causing issues.

On Sat, Jul 6, 2019 at 8:26 PM Robert C notifications@github.com wrote:

I cannot normalize the colors on a pcolormesh plot.

For example, I can usually normalize a colormap: plt.imshow(data,vmin=-4,vmax=4,cmap=plt.cmap.jet)

However, when using the pcolormesh basemap plotting feature, I cannot normalize the data:

m1.pcolormesh(lons,lats,data,shading='flat',cmap=plt.cm.jet,vmin=-4,vmax=4,latlon=True,rasterized=True)

The data simply remains normalized to the max and min value of the data. I've tried using mcolors.Normailze and setting the norm parameter in pcolormesh, and also tried changing the clim values, but nothing works. No matter what when plotting pcolormesh on a basemap I cannot change the normalization of the colormap.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/matplotlib/basemap/issues/468?email_source=notifications&email_token=AACHF6C7WD2XQIQCA23EDCDP6EZ3JA5CNFSM4H6UQGR2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G5V2ZEA, or mute the thread https://github.com/notifications/unsubscribe-auth/AACHF6BMDA3ZXDR2AL2HV53P6EZ3JANCNFSM4H6UQGRQ .

efiring commented 5 years ago

shading='flat' is just specifying a valid option that is in fact the default, so it's hard to see how that would cause a problem.

@ricitron, would you provide a very simple, clear, and self-contained example, please, so we can reproduce it? The shorter and simpler, the better.