使用groupby与熊猫制作箱形图

时间:2020-01-14 16:11:23

标签: pandas

我在熊猫框架中具有以下多索引数据结构

enter image description here

使用以下代码,我设法绘制了一个条形图,其中不同的“刺激”组显示为相邻的条形。

posx = center['posx'].loc[(slice(None),slice(None),'post')]
posx_mean = speed.groupby(['line','stimulation']).mean()
posx_std = speed.groupby(['line','stimulation']).std()

posx_mean.unstack().plot(kind='bar', yerr=posx_std.unstack(), figsize = (15,3))

enter image description here

但是,我想将数据绘制为箱形图,并显示所有数据点。箱形图应准确地模拟条形图的结构,即“刺激”组在x轴上“线”的顶部显示为相邻的框,并且最好使用不同的颜色。

有人可以帮我吗?

0 个答案:

没有答案