我了解到在matplotlib的箱线图函数中,须的末端延伸到75%+1.5 IQR以下的最大值和25%-1.5 IQR以上的最小值。我想改变这种表示方式,以表现数据的最大和最小值或数据的第5个和第95个四分位数。是否可以实现这一点?
我了解到在matplotlib的箱线图函数中,须的末端延伸到75%+1.5 IQR以下的最大值和25%-1.5 IQR以上的最小值。我想改变这种表示方式,以表现数据的最大和最小值或数据的第5个和第95个四分位数。是否可以实现这一点?
whis
参数设置为任意大的数字。换句话说:boxplots = ax.boxplot(myData, whis=np.inf)
。
whis
参数是四分位距的缩放因子。须绘制到距离四分位数whis * IQR
之外的最外数据点。boxplots = ax.boxplot(myData, whis=[5, 95])
来将须设置为第5个和第95个百分位数。类似地,您可以使用boxplots = ax.boxplot(myData, whis=[0, 100])
将须设置为最小值和最大值。ax.boxplot
方法返回的boxplots
字典中包含的艺术家,但这似乎非常麻烦。#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)