[英]Matplotlib: Plotting a dataframe with multiple subplots
I have the following dataframe:我有以下 dataframe:
Date & Time Amount Count
Aug 2022 $10.50 53
$14.00 1
$3.50 416
$35.00 186
Jul 2022 $14.00 1
$3.50 844
$35.00 307
Jun 2022 $14.00 1
$3.50 797
$35.00 323
I'm trying to use Matplotlib so that I can plot a bar graph (really a histogram) with the months/year as the xticks for the bigger plot, the amounts as xticks for the subplots, and the counts as the Y value. I'm trying to use Matplotlib so that I can plot a bar graph (really a histogram) with the months/year as the xticks for the bigger plot, the amounts as xticks for the subplots, and the counts as the Y value. Something like this:像这样的东西:
The kicker is that the number of "Amount" values for each month can vary.更重要的是,每个月的“金额”值的数量可能会有所不同。
I'm stumped on how to do this one.我对如何做到这一点感到困惑。
I achieved this easily by installing Seaborn and adding the following code after the dataframe:我通过安装 Seaborn 并在 dataframe 之后添加以下代码轻松实现了这一点:
ndf = (DATAFRAME)
ndf = ndf.reset_index()
ploot = sns.barplot(x='Date & Time',y='Count',hue='Amount',data=ndf)
ploot.invert_xaxis()
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.