Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Matplotlib:更改记号之间的间距_Python_Matplotlib_Plot - Fatal编程技术网

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])