我正在尝试创建一个包含两种颜色类别的水平条形图,一种用于2015年,另一种用于2016.数据框如下所示:
mc_math_sorted_districts15
Out[98]:
Both Met and Exceeded District Name
31943 0.0 San Lucas Union Elementary
733 7.0 Monterey County Office Of Education
13578 9.0 South Monterey County Joint Union High
42319 12.0 Gonzales Unified
3130 13.0 Alisal Union
31427 13.0 San Ardo Union Elementary
23746 14.0 Salinas City Elementary
36709 14.0 North Monterey County Unified
mc_math_sorted_districts16
Out[99]:
Both Met and Exceeded District Name
31990 3.0 San Lucas Union Elementary
31491 8.0 San Ardo Union Elementary
735 9.0 Monterey County Office Of Education
13584 13.0 South Monterey County Joint Union High S
23727 15.0 Salinas City Elementary
11936 16.0 King City Union School District
42534 16.0 Gonzales Unified School District
10563 16.0 Greenfield Union Elementary
36782 17.0 North Monterey County Unified School Dis
我希望图表的x轴是“Both Met和Exceeded”列(每个数据框的颜色不同)。我一直在使用以下代码,但我一次只能绘制一个数据帧。
ax = mc_math_sorted_districts15[['Both Met and Exceeded']].plot(kind='barh', title ="Percentage Met or Exceeded by District-Math 2015", figsize=(15, 10), legend=True, fontsize=12)
ax.set_xlabel("Percentage Met or Exceeded", fontsize=12)
ax.set_ylabel("District Name", fontsize=12)
plt.show()
有没有办法在同一个图中添加两列?