【发布时间】:2024-01-18 18:22:01
【问题描述】:
我无法在此数据集上绘制条形图。
+------+------------+--------+
| Year | Discipline | Takers |
+------+------------+--------+
| 2010 | BSCS | 213 |
| 2010 | BSIS | 612 |
| 2010 | BSIT | 796 |
| 2011 | BSCS | 567 |
| 2011 | BSIS | 768 |
| 2011 | BSIT | 504 |
| 2012 | BSCS | 549 |
| 2012 | BSIS | 595 |
| 2012 | BSIT | 586 |
+------+------------+--------+
我正在尝试绘制一个条形图,其中 3 个条形表示每年的接受者数量。这是我做的算法。
import matplotlib.pyplot as plt
import pandas as pd
Y = df_group['Takers']
Z = df_group['Year']
df = pd.DataFrame(df_group['Takers'], index = df_group['Discipline'])
df.plot.bar(figsize=(20,10)).legend(["2010", "2011","2012"])
plt.show()
我希望展示类似这张图的东西
有着相同的传说
【问题讨论】:
标签: python python-3.x pandas matplotlib jupyter-notebook