我想为我的数据创建堆叠子图。我希望以“类型”和“星期”作为我的X轴,以“分数”为堆叠的子图。
np.random.seed(1234)
test = pd.DataFrame({'week':[1,1,1,1,1,1,2,2,2,2,2,2],
'score':np.random.uniform(0,1,12),
'type': [0,1,0,1,0,1,0,1,0,1,0,1],
'type2':[3,3,4,4,5,5,3,3,4,4,5,5]})
这是我现在拥有的内容,如果我添加一个名为“subplot = True”的参数。
test.groupby(['week','type','type2']).agg('sum').unstack(1).plot(kind='bar', subplots=True)
plot
调用所对应的代码。这将有助于准确理解你想做什么。 - Romain