Matplotlib 指定绘图日期()的勾号格式?
我正在使用:Matplotlib 指定绘图日期()的勾号格式?,matplotlib,Matplotlib,我正在使用: matplotlib '1.1.1rc' ipython 0.12.1 ipython notebook --pylab inline --no-browser 我生成一个图形,其中包含: xticks(rotation='vertical') plot_date(ts, percent, xdate=True) 其中ts是跨越几天的日期时间列表。我得到: 注意x轴;它只显示日期时间的时间部分。如何使其同时显示日期?如果您查看for matplotlibsdatetime如果
matplotlib '1.1.1rc'
ipython 0.12.1
ipython notebook --pylab inline --no-browser
我生成一个图形,其中包含:
xticks(rotation='vertical')
plot_date(ts, percent, xdate=True)
其中ts是跨越几天的日期时间列表。我得到:
注意x轴;它只显示日期时间的时间部分。如何使其同时显示日期?如果您查看for matplotlibsdatetime
如果您遵循类似的想法,则可以指示绘图工具如何格式化行中的记号:
from matplotlib.dates import DateFormatter
ax.xaxis.set_major_formatter( DateFormatter('%Y-%m-%d') )
将字符串更改为
"%Y-%m-%d %H:%M:%S"
威尔在他们的例子中有时间去做x记号 Pandas通常非常适合于时间序列和数据分析,它有一个围绕matplotlib的包装器,可以为您解决大部分问题。在您的示例中,您可能只需执行以下操作:
import pandas as pd
df = pd.DataFrame(ts) # to get your series into a pandas dataframe
df.plot()
plot.show()
它将优雅地处理日期格式和诸如此类的事情。看