gpt4 book ai didi

python - 绘制数据框时 X 轴不显示

转载 作者:行者123 更新时间:2023-12-01 01:22:29 25 4
gpt4 key购买 nike

嗨,我有一个数据框,其中日期作为索引,股份作为列我想使用日期作为 x 轴绘制特定份额。我想要绘制的系列是:df['APPL']=

Date
2018-10-29 24.903347
2018-10-30 25.165384
2018-10-31 25.087744
2018-11-01 24.777180
...
2018-12-06 25.709999

但是当我用 df['APPL'].plot(use_index=True 绘制出来时),xasix 未显示。然后我尝试了plt.plot(df.index,df['APPL']) ,x轴间隔太小,无法读取。 enter image description here 。例如,如何增加间隔以每 10 天显示一次?

最佳答案

您可以旋转:

plt.xticks(rotation=90)

演示:

plt.plot(df.index,df['APPL'])
plt.xticks(rotation=90)

旋转后,文本将旋转90度。

如果您愿意:

plt.plot(df.index,df['APPL'])
plt.xticks(rotation=45)

测试一下你喜欢哪个。

关于python - 绘制数据框时 X 轴不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53688631/

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