whis = [5,95]
我对其他主题和帮助文档的理解是,这是正确的语法,但我是python的新手,可能会出错...
为了清楚起见,这里是导致错误的命令:
bp = boxplot(data [0],position = [1],widths = 0.6,whis = [5,95])
> Traceback (most recent call last):
> File "boxplot_snoho_bc.py", line 125, in <module>
> main()
> File "boxplot_snoho_bc.py", line 64, in main
> bp = boxplot(data[0], positions = [1], widths = 0.6, whis = [5,95])
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2143, in boxplot
> ret = ax.boxplot(x, notch, sym, vert, whis, positions, widths, patch_artist, bootstrap)
> File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 5545, in
> boxplot
> wisk_hi = np.compress( d <= hi_val , d )
> ValueError: operands could not be broadcast together with shapes (10) (42)
是一个8x10的numpy数组;我一次只绘制一个方框。这是数组的样子:
打印数据
[[40.66 33.53 30.56 30.83 11.8 60.91 11.91 10.74 23.97 11.]
[16.19 85.69 206.25 27.16 29.22 41.69 16.44 10.41 477.75 23.95]
[1651. 192. 16.02 29.91 14.95 123.38 31.22 11.08 29.5 16.03]
[132.5 874.5 12.51 41.5 68.25 60.22 36.91 12.27 58.84 28.33]
[145.5 26.95 25.2 33.88 44.78 40.16 16.78 18.95 36.03 16.05]
[18.89 82.94 83.56 344. 118.94 49.62 23.23 25.89 2072. 90.56]
[221.38 22.69 35.28 25.08 25.16 41.84 16.77 14.16 12.77 15.27]
[32.03 1634. 34.59 140.12 61.22 32.53 24.55 20.06 30.97 27.14]]
答案 0 :(得分:0)
问题解决了。令人尴尬的是,这是matplotlib的版本问题(至少需要1.4.0版本)。