gpt4 book ai didi

python - 如何在 matplotlib 中调整 x 轴

转载 作者:行者123 更新时间:2023-11-28 22:02:03 26 4
gpt4 key购买 nike

我有这样的图表 enter image description here

x轴上的数据表示小时,所以我希望x轴设置为0,24,48,72.....而不是现在的值,很难看到[0,100]之间的数据

fig1 = plt.figure()  
ax = fig1.add_subplot(111)
ax.set_yscale('log')
ax.plot(x,y,'b-')

根据第一个答案,我得到了这个: enter image description here

最佳答案

查看docs :

xlocs, xlabs = plt.xticks()

在 xlocs 中输入你的范围,在 xlabs 中输入你想要显示的内容。

然后:

 plt.xticks(xlocs, xlabs)

关于python - 如何在 matplotlib 中调整 x 轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12109648/

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