If I have an existing pcolormesh() object is it possible to change the vmin, vmax values? In other words, are vmin and vmax attributes of the pcolormesh object?
>Solution :
To see an object’s attributes you can use the dir function.
p = plt.pcolormesh(...)
print(dir(p)) # lists all the attributes for this object
You’ll see it has the .set_clim() attribute which you can use.
import numpy as np
import matplotlib.pyplot as plt
plt.close("all")
x = np.linspace(0, 1)
y = np.linspace(0, 1)
Z = x[:,None]**2 + y[None, :]**2
fig, ax = plt.subplots()
p = ax.pcolormesh(x, y, Z)
fig.colorbar(p, ax=ax)
fig.show()
fig, ax = plt.subplots()
p = ax.pcolormesh(x, y, Z)
p.set_clim(vmin=0.5, vmax=1.)
fig.colorbar(p, ax=ax)
fig.show()
First figure:
Second figure:

