繁体   English   中英

在Pandas中,无法很好地显示x轴日期和不必要的日志中的y轴

[英]In Pandas, can't show x-axis dates nicely and y-axis in unwanted logs

这是我的图表:

在此处输入图片说明

我有两个问题; 我无法很好地显示x轴上的datetime对象(即2013年1月1日),并且我希望y轴标签为绝对值,而不是对数值。

这是我的注释代码:( date_sorted是我的Pandas数据date_sorted

fig = plt.figure()
date_sorted.plot( x = ["ReleaseDate"], y = ["DomesticTotalGross"])
plt.title("Domestic Total Gross over Time")
plt.xticks(rotation=45)
plt.yscale('linear') # ---- this doesn't seem to do anything
plt.ticklabel_format(useOffset=False) #--- this gives this error: AttributeError: This method only works with the ScalarFormatter.
fig.autofmt_xdate() #thought this was supposed to convert my x-axis datetime objects into nice dates?

关于日期格式,一种实现目标的方法是将索引重置为日期格式,而不是日期时间:

date_sorted.set_index([ts.date for ts in date_sorted.index]).plot(x="ReleaseDate", y="DomesticTotalGross")

暂无
暂无

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

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