我的 Pandas 数据框 df 的头部如下所示:
count1 count2 totalcount season
0 3 13 16 1
1 8 32 40 1
2 5 27 32 1
3 3 10 13 1
4 0 1 1 1
我想绘制 count1、count2 和 totalcount 的箱线图,按 season 分组(有 4 个季节),并让每组箱线图显示在单个图中的各自子图中。
当我只对其中的两列执行此操作时,比如 count1 和 count2,一切看起来都很棒。
df.boxplot(['count1', 'count2'], by='season')
但是当我将 totalcount 添加到组合中时,轴限制变得困惑。
df.boxplot(['count1', 'count2', 'totalcount'], by='season')
无论列的顺序如何,都会发生这种情况。我知道有几种方法可以解决这个问题,但如果它正常工作会方便得多。
我错过了什么吗?这是 Pandas 中的已知错误吗?我在第一遍 Pandas 错误报告中找不到任何内容。
我使用的是 Pandas 0.14.0 和 matplotlib 1.3.1。
请您参考如下方法:
您是否尝试过升级您的 pandas/matplotlib 软件包?
我正在使用 Pandas 0.13.1 + Matplotlib 1.2.1,这是我得到的图:
In [31]: df
Out[34]:
count1 count2 totalcount season
0 3 13 16 1
1 8 32 40 1
2 5 27 32 1
3 3 10 13 1
4 0 1 1 1
5 3 13 16 2
6 8 32 40 2
7 5 27 32 3
8 3 10 13 3
9 0 1 1 4
10 3 10 13 4
11 3 13 16 4
[12 rows x 4 columns]
