【发布时间】:2020-10-15 07:31:42
【问题描述】:
我有五个数据框
pt car walk bike
Normal day 28.80 36.82 30.83 3.55
start 28.82 36.83 30.80 3.55
Equilibrium 28.51 36.95 30.98 3.56
Medium 31.74 33.80 32.23 2.23
Equilibrium2 32.06 34.04 30.78 3.12
我用下面的代码
fig, axes = plt.subplots(3, 3, figsize=(14, 10))
colors = ['yellowgreen','lightcoral','pink','lightskyblue']
for i, (idx, row) in enumerate(df.iterrows()):
ax = axes[i // 3, i % 3]
row = row[row.gt(row.sum() * .001)]
#ax.pie(row, autopct='%1.1f%%',startangle=30, color=colors)
ax.pie(row, colors=colors,
autopct='%0.01f%%', startangle=30, pctdistance=0.7, radius=1)
ax.set_title(idx)
#fig.legend(('pt','transit_walk','car', 'walk', 'bike'), prop={'size': 8}, title = 'Scenarios')
fig.legend(labels=df.columns,fontsize= 14,loc="center right")
fig.subplots_adjust(hspace=0.1, wspace=0.01)
如何将它们结合起来?
【问题讨论】:
标签: pandas dataframe pie-chart