【发布时间】:2020-11-05 06:58:23
【问题描述】:
这是我的数据框(命名为人口普查):
Ethnicity USA All CA All USA Children CA Children
0 Black 0.12 0.05 0.14 0.05
1 Hispanic 0.18 0.38 0.24 0.50
2 White 0.62 0.39 0.52 0.29
3 Other 0.08 0.18 0.10 0.16
我试图显示平行图,但似乎无法找到我哪里出错了 这是我的代码:
error im facing:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-32-c9aa8709606a> in <module>
----> 1 fig, (ax1,ax2,ax3,ax4) = plt.subplots(nrows = 2, ncols = 2)
2 plt.tight_layout()
3 ax1 = census[['USA All','CA All','Ethnicity']]
4 ax1.plot.barh()
5
ValueError: not enough values to unpack (expected 4, got 2)
fig, (ax1,ax2,ax3,ax4) = plt.subplots(nrows = 2, ncols = 2)
plt.tight_layout()
ax1 = census[['USA All','CA All','Ethnicity']]
ax1.plot.barh()
ax2 = census[['USA All','CA Children','Ethnicity']]
ax2.plot.barh()
ax3 = census[['USA Children','CA Children','Ethnicity']]
ax3.plot.barh()
ax4 = census[['USA All','USA Children','Ethnicity']]
ax4.plot.barh()
plt.tight_layout()
【问题讨论】:
标签: matplotlib subplot