簡體   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