开发者社区 问答 正文

Matplotlib:改变刻度之间的间隔

我正在绘制一个二维数组使用pcolormesh的matplotlib使用这个代码:

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个刻度之间的距离相同有人知道怎么做吗? 问题来源StackOverflow 地址:/questions/59466193/matplotlib-changing-the-spacing-between-ticks

展开
收起
kun坤 2019-12-25 13:52:10 352 分享 版权
0 条回答
写回答
取消 提交回答
问答分类:
问答标签:
问答地址: