gpt4 book ai didi

python-3.x - 在 plt.Matshow 上从上到下更改 x 轴位置

转载 作者:行者123 更新时间:2023-12-01 03:01:43 31 4
gpt4 key购买 nike

我已经搜索过 high 和 low ,但我似乎无法使用 Matshow 从上到下移动 x 轴,我知道 imshow 具有从上到下更改 x 轴位置的原始代码,但是问题我坚持要使用 Matshow,因此有没有办法切换 a 轴位置?
t = [[(x+y+1)%2 for x in range(7)] for y in range (7)]
plt.matshow(t, interpolation="none")
plt.title('ArrayD')

最佳答案

调用tick_bottom() :

plt.matshow(t, interpolation="none")
plt.gca().xaxis.tick_bottom()

或使用 imshow而不是 matshow :
plt.imshow(t, interpolation="none")
import numpy as np
import matplotlib.pyplot as plt

t = [[(x+y+1)%2 for x in range(7)] for y in range (7)]
plt.matshow(t, interpolation="none")
plt.title('ArrayD', y=1.01)
plt.gca().xaxis.tick_bottom()
plt.show()

产量

enter image description here

关于python-3.x - 在 plt.Matshow 上从上到下更改 x 轴位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40076816/

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