Python 一次画多幅图
我想使用matplotlib和pandas绘制绘图。 在熊猫中,我有价格数据和该价格的日期。所有年份都在一个文件中。在图中,我想得到许多图,用于比较涨价/降价的月份,每种颜色都意味着某一年。 因此,我的问题是,从matplotlib或pandas到不每年提取和其他小问题,有没有简单的解决方案?答案是“pivot\u table” 因此,类似任务的代码如下所示:Python 一次画多幅图,python,pandas,matplotlib,Python,Pandas,Matplotlib,我想使用matplotlib和pandas绘制绘图。 在熊猫中,我有价格数据和该价格的日期。所有年份都在一个文件中。在图中,我想得到许多图,用于比较涨价/降价的月份,每种颜色都意味着某一年。 因此,我的问题是,从matplotlib或pandas到不每年提取和其他小问题,有没有简单的解决方案?答案是“pivot\u table” 因此,类似任务的代码如下所示: url="https://hotline.ua/temp/charts/102320/63price.csv" fixed_df_t
url="https://hotline.ua/temp/charts/102320/63price.csv"
fixed_df_t = pd.read_csv(url, sep=';', parse_dates=[0],
dayfirst=True, names=["Date", "Price"],
index_col='Date')
r = fixed_df_t[['Price']].assign(year=fixed_df.index.year,
month=fixed_df.index.month) \
.pivot_table(index='month', columns='year',
values='Price', aggfunc='mean')
r.plot(legend=True, figsize=(15, 10))
您应该提供您的数据(或示例)和迄今为止您试图解决问题的代码。@DavideBrex示例: