简体   繁体   English

Python 在 x 轴上绘制多年数据的日​​时间

[英]Python Plot day time on x-axis for many years of data

I am plotting many years of data.我正在绘制多年的数据。 On the x-axis, I am plotting time of the day and on y-axis the value.在 x 轴上,我正在绘制一天中的时间,在 y 轴上绘制值。 The problem is x-axis ticks builtup together, not visible.问题是 x 轴刻度组合在一起,不可见。 How do I solve it?我该如何解决?

plt.plot(df.index.strftime('%H:%M'),df['ydata'],'.')#hour+ssdf.index.minute/60
plt.gcf().autofmt_xdate()
plt.show()

在此处输入图片说明

In the above plot, I wanted to see the x-axis ticks show 00:00, 02:00, etc.在上图中,我想看到 x 轴刻度显示 00:00、02:00 等。

You can try the first answer from this post .你可以试试这个帖子的第一个答案。

Reducing the number of xticks by using plt.xticks will change the frequency of items appearing.使用plt.xticks减少 xticks 的数量将改变项目出现的频率。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM