gpt4 book ai didi

matplotlib - 为 plot_date() 指定刻度格式?

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

我正在使用:

matplotlib '1.1.1rc'
ipython 0.12.1
ipython notebook --pylab inline --no-browser

我生成一个图表:

xticks(rotation='vertical')
plot_date(ts, percent, xdate=True)

其中 ts 是跨越几天的日期时间列表。我得到:

enter image description here

注意 x 轴;它只显示日期时间的时间部分。我如何让它也显示日期?

最佳答案

如果你看一下 standard example对于 matplotlibs datetime 如果您遵循类似的想法,那么您可以指示绘图工具如何格式化行中的刻度:

from matplotlib.dates import  DateFormatter
ax.xaxis.set_major_formatter( DateFormatter('%Y-%m-%d') )

将字符串更改为

"%Y-%m-%d %H:%M:%S" 

将有时间在他们的示例中进行 x 滴答。

关于matplotlib - 为 plot_date() 指定刻度格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20922384/

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