gpt4 book ai didi

python - pcolormesh 与坐标的奇怪行为

转载 作者:太空宇宙 更新时间:2023-11-04 03:10:38 25 4
gpt4 key购买 nike

我想使用 matplotlib 的 pcolormesh 函数绘制颜色网格。但是,它会根据我是否指定坐标给出不同的结果。

import numpy as np
from matplotlib import pyplot as plt

np.random.seed(9)
x = np.arange(10)
z = np.random.normal(0, 1, (10, 10))

plt.subplot(121)
plt.pcolormesh(x, x, z)

plt.subplot(122)
plt.pcolormesh(z)

我希望这两个调用产生相同的图像,但最终会出现以下情节。例如,绘图的右上角不同。

comparison

最佳答案

来自帮助(pcolor)

...
Ideally the dimensions of X and Y should be one greater than those of C;
if the dimensions are the same, then the last row and column of C will be ignored. ...

您得到的左侧图是右侧图的放大图,其中删除了顶行和最右侧的列。

关于python - pcolormesh 与坐标的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38143466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com