I am trying to plot a pcolor plot on a map using Basemap. This is my current code:
# Plot Data
cs = m.pcolor(xi,yi,np.squeeze(elev),norm=colors.LogNorm(vmin=elev.min(),vmax=elev.max()),cmap=cmocean.cm.deep_r)
# Add Colorbar
cbar = m.colorbar(cs, location='bottom', pad="10%")
cbar.set_label(elev_units)
plt.show()
This then gives me the following error when reaching the cbar line:
ValueError: Invalid vmin or vmax
I've tried to move the vmin and vmax outside the LogNorm argument and also into the .colorbar function to no avail. How do I get a log scale on my pcolor plot?
elev.min()is a negative number, which the log function doesn't like. For vmin and vmax you'll have to scale the values so that they are both positive (a value of zero won't work either).