这是我正在处理的csv文件的要点:
CODE AGEGROUP SEX CITY HEALTHSTATUS
---- --------- --- ---- ------------
E101 25 to 29 M Denver Recovered
E102 25 to 29 F Chicago Recovered
E105 45 to 49 M Denver Mild
我希望用条形图来表示这一点,但对于如何编写子图,我感到相当困惑。在这段代码中,我可以尽可能显示有多少男性和女性受到影响,但我无法显示健康状况和年龄组:
import matplotlib.pyplot as plt
plt.style.use("bmh")
x = df2["SEX"]
y = df2["SEX"].value_counts().plot(kind="bar")
plt.xlabel("Sex", fontsize=12)
plt.ylabel("Number of People", fontsize=12)
plt.title("Number of people affected based on sex", fontsize=12)
plt.show()
我如何显示其他两个(健康状况和年龄组)
百分比栏:
我想应该是这样的(ps):
但plt是:
守则如下:
一种方法是为每个条件创建单独的子批次:
相关问题 更多 >
编程相关推荐