Python 3.x 在Python中从单个行绘制子图

Python 3.x 在Python中从单个行绘制子图,python-3.x,matplotlib,plot,subplot,figure,Python 3.x,Matplotlib,Plot,Subplot,Figure,我有以下数据帧: UserId Gold Silver Bronze TagBased TotalBadges 0 854 1 7 22 2 30 1 5740 6 42 114 12 162 2 26 7 68 168 1 243 3 8884 14 94 229 3 337 我想为个

我有以下数据帧:

   UserId   Gold Silver Bronze TagBased TotalBadges
0   854      1     7    22       2         30
1   5740     6    42    114     12        162
2   26       7    68    168      1        243
3   8884    14    94    229      3        337
我想为个人用户制作展示他们的金牌、银牌和铜牌的子图。因此,我总共需要这4个用户的4个子包

我已经尝试了以下代码,但它没有给出任何输出

fig = plt.figure()

ax0=fig.add_subplot(221)
ax1=fig.add_subplot(222)
ax2=fig.add_subplot(223)
ax3=fig.add_subplot(224)

for index,rows in df_tagBased.iterrows():
  df_tagBased['UserId'=='854'].plot(kind = 'hist',ax=ax0,figsize = (15,8))

您可以执行
设置索引
并绘制转置:

(df.set_index('UserId')[['Gold','Silver','Bronze']]
   .T.plot.bar(subplots=True,layout=(2,2))
)
输出:


这是可行的,但是您能告诉我如何使用我提供的代码实现同样的效果吗。