如何在matplotlib中调整x轴 [英] how to adjust x axis in matplotlib
本文介绍了如何在matplotlib中调整x轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的图表
x轴上的数据表示小时,因此我希望将x轴设置为0、24、48、72....而不是现在的值,这很难看到[0,100]之间的数据
The data on the x axis means hours, so I want the x axis to set as 0, 24, 48, 72.....instead of the value now, which is difficult to see the data between [0,100]
fig1 = plt.figure()
ax = fig1.add_subplot(111)
ax.set_yscale('log')
ax.plot(x,y,'b-')
根据第一个答案,我得到了:
According to the the first answer, I got this:
推荐答案
看文档 :
xlocs, xlabs = plt.xticks()
在 xlocs 中输入您的范围,并在 xlabs 中输入您想要显示的内容.
put in xlocs your range, and in xlabs what you want to display.
然后:
plt.xticks(xlocs, xlabs)
这篇关于如何在matplotlib中调整x轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文