-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Labels
Description
Using the LogNorm
colormap argument in, e.g., pcolormesh
doesn't work correctly in proplot
.
Data link: http://s000.tinyupload.com/index.php?file_id=02946064711977690771
With matplotlib:
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import matplotlib.colors as colors
ds = xr.open_dataset('chl_cal.nc')
f, ax = plt.subplots(subplot_kw=dict(projection=ccrs.PlateCarree()))
p = ax.pcolormesh(ds.lon, ds.lat, ds, norm=colors.LogNorm(vmin=ds.min(), vmax=ds.max()))
plt.colorbar(p)
With proplot:
f, ax = plot.subplots(proj='pcarree', tight=False, axwidth=6, colorbar='r')
p = ax.pcolormesh(ds.lon, ds.lat, ds.values, norm=colors.LogNorm(vmin=ds.min(), vmax=ds.max()))
ax.set_extent([-140, -105, 20, 50])
f.rightpanel.colorbar(p)
Here's a workaround, but I think using LogNorm
is preferred so it handles the labeling and all that for you. Now this is of course in actual log10 units.
# Just log-transform before
ds = np.log10(ds)
f, ax = plot.subplots(proj='pcarree', tight=False, axwidth=6, colorbar='r')
p = ax.pcolormesh(ds.lon, ds.lat, ds.values,)
ax.set_extent([-140, -105, 20, 50])
f.rightpanel.colorbar(p)