import matplotlib.pyplot as plt
import numpy as np
np.random.seed(19860801)Z= np.random.rand(3,5) # C is a parameter in the pcolormesh, it should at least smaller than the len of x, y.
# there is a problem i can't solve.
# x = np.arange(-0.5,10,1) # len =11
# y = np.arange(4.5,11,1) # len =7
x = np.arange(-0.5,10,2) # len =6
y = np.arange(4.5,11,2) # len =4
plt.pcolormesh(x, y,Z)
fig, ax = plt.subplots()
x1, y1 = np.meshgrid(x, y)
x1 = x1 +(0.2* y1)
y1 = y1 +(.3* x1)
plt.pcolormesh(x1, y1,Z)
plt.show()
Center Coordinate
import matplotlib.pyplot as plt
import matplotlib
from matplotlib.ticker import MaxNLocator
from matplotlib.colors import BoundaryNorm
import numpy as np
np.random.seed(19860801)Z= np.random.rand(6,10)
x = np.arange(-0.5,10,1)
y = np.arange(4.5,11,1)
plt.pcolormesh(x, y,Z)
x1, y1 = np.meshgrid(x, y)
x1 = x1 +(y1*0.2)
y1 = y1 +(x1 *0.2)
plt.pcolormesh(x1, y1,Z)Z= np.random.rand(6,10)
fig, ax = plt.subplots(2,1, sharex=True, sharey=True)
x = np.arange(10)
y = np.arange(6)
x2, y2 = np.meshgrid(x, y)
ax[1].pcolormesh(x2, y2,Z, vmin=np.min(Z), vmax=np.max(Z), shading='auto')
ax[1].set_title('auto')
ax[0].pcolormesh(x2, y2,Z[:-1,:-1], vmin=np.min(Z), vmax=np.max(Z), shading='flat')
ax[0].set_title('flat')
plt.show()
Matplotlib自学打卡day5pcolormeshpcolormeshimport matplotlib.pyplot as pltimport numpy as npnp.random.seed(19860801)Z = np.random.rand(3, 5) # C is a parameter in the pcolormesh, it should at least smaller than the len of x, y.# there is a problem i c