0
這裏是我的代碼:熊貓區地塊軸標籤
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'col_1':[1,2,3], 'col_2': [3,4,5],
'date_col': ['2014-12-15','2015-11-07','2016-01-10']})
df['date_col'] = pd.to_datetime(df['date_col']).dt.date
df.plot.area(x = 'date_col', y = ['col_1', 'col_2'])
plt.show()
它生產區地塊如預期,但也有更多的X軸標籤,然後我需要的。在數據框中我只需要3個標籤。有什麼建議麼?
對不起,它不工作,所有的日期在一個地方,整個情節是扭曲的。 – user1700890
你的意思是*所有日期都在一個地方*?如果日期靠得很近,那麼你很可能會被粘在一起的標籤結束。從你在這裏分享的數據中,我可以得到你所描述的所需輸出。 – Abdou
appologies,您的代碼完美地工作。我忘了我的代碼中還有以下代碼:'df ['date_col'] = pd.to_datetime(df ['date_col'])。dt.date' – user1700890