我有一个DataFrame:
index 0 1 2 3 4 5
1 12 13 14 15 13 12
df.plot()
x轴的范围是0-5,但是我想更改为1-6,并且不想通过df.columns = df.columns + 1
更改列的标题值。
答案 0 :(得分:1)
您可以从df.plot()
返回轴对象,然后使用函数set_xticklabels()
修改x轴刻度标签:
ax = df.plot()
ax.set_xticklabels([1,2,3,4,5,6])
请注意,这使用了pandas / matplotlib自动生成的刻度位置。