1

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?

1
  • 2
    The problem is probably that 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). Commented Jan 30, 2023 at 15:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.