在x轴上添加更多标签python matplotlib [英] add more labels to the x axis python matplotlib
本文介绍了在x轴上添加更多标签python matplotlib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的原始图形:
我没有更改xticklabel或其他任何东西,只做了 plot(x,y)
,标签会根据x值自动生成.
I didn't change the xticklabels or anything, I only did plot(x,y)
, the labels are automatically generated according to the x values.
但是我想将 x 标签更改为 [0,24,48,72....480,504]
However I want to change the x label to [0,24,48,72....480,504]
这是我做的
ax.plot(x1,y1)
xlabel =[]
xinterval = np.arange(0,504,24)
ax.set_xticks=(xinterval)
ax.set_xticklabels(xinterval)
结果是:
这显然是错误的,有人可以帮忙吗?
which is obviously wrong, could anyone help?
推荐答案
您有错字;它应该是 ax.set_xticks(xinterval)
,没有 =
.
You have a typo; it's supposed to be ax.set_xticks(xinterval)
, without the =
.
不需要 set_xticklabels
命令.
这篇关于在x轴上添加更多标签python matplotlib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文