Python Matplotlib:更改记号之间的间距
我正在使用Python Matplotlib:更改记号之间的间距,python,matplotlib,plot,Python,Matplotlib,Plot,我正在使用matplotlib的pcolormesh绘制二维数组,使用以下代码: import matplotlib.pyplot as plt import numpy as np # generate 2 2d grids for the x & y bounds y = np.linspace(1/2.0,2.0,100) x = np.linspace(0.00001,2,100) y, x = np.meshgrid(y,x) z = (1 - x / 2. + x **
matplotlib
的pcolormesh
绘制二维数组,使用以下代码:
import matplotlib.pyplot as plt
import numpy as np
# generate 2 2d grids for the x & y bounds
y = np.linspace(1/2.0,2.0,100)
x = np.linspace(0.00001,2,100)
y, x = np.meshgrid(y,x)
z = (1 - x / 2. + x ** 5 + y ** 3) * np.exp(-x ** 2 - y ** 2)
z = z[:-1, :-1]
z_min, z_max = -np.abs(z).max(), np.abs(z).max()
plt.pcolormesh(x, y, z)
# set the limits of the plot to the limits of the data
plt.axis([x.min(), x.max(), y.min(), y.max()])
plt.colorbar()
我得到这个数字:
我希望y轴上1/2和1个刻度之间的距离与1和2个刻度之间的距离相同-有人知道如何做到这一点?为什么不将y轴设为对数
plt.pcolormesh(x, y, z)
plt.yscale('log')
plt.yticks([0.5,1,2],[0.5,1,2])