据我所知,matplotlib方格图函数中的晶须末端扩展到最大值小于75% + 1.5 IQR,最小值扩展到25% - 1.5 IQR以上。我想改变它来表示数据的最大值和最小值,或者数据的第5和第95四分位数。这是可能的吗?
发布于 2014-02-24 20:45:01
要使晶须出现在数据的最小值和最大值处,请将whis参数设置为任意大的数目。换句话说:boxplots = ax.boxplot(myData, whis=np.inf)。
whis kwarg是四分位数范围的缩放因子。在远离四分位数的whis * IQR中,晶须被吸引到最外层的数据点。
现在1.4版已经过时了:
在matplotlib v1.4中,您可以说:boxplots = ax.boxplot(myData, whis=[5, 95])将晶须设置为第5和第95百分位数。同样,你也可以说boxplots = ax.boxplot(myData, whis=[0, 100])将晶须设置在最小和最大。
注意:您可能可以修改由boxplots方法返回的ax.boxplot字典中包含的艺术家,但这似乎是一个巨大的麻烦。
发布于 2014-04-28 18:57:31
设置方框选项whisk=0以隐藏内置的胡须。然后创建自定义胡须,显示数据从5%到95%。
#create markings that represent the ends of whiskers
low=data.quantile(0.05)
high=data.quantile(0.95)
plt.scatter(range(1,len(low)+1),low,marker='_')
plt.scatter(range(1,len(low)+1),high,marker='_')
#connects low and high markers with a line
plt.vlines(range(1,len(low)+1),low,high)这应该创造垂直线,在盒子后面的胡须标记在5%,95%。
https://stackoverflow.com/questions/21997897
复制相似问题