【发布时间】:2020-08-21 14:22:33
【问题描述】:
我正在尝试使用 matlotlib 来控制使用 seaborn 生成的“缺口”箱形图中异常值的外观。我的代码如下所示:
ax = sns.boxplot(y= "class", x = "Proba",hue = "Stage", data = df_tidy, notch = True,
showmeans= True, meanprops={"marker": ".", "markerfacecolor":"red", "markeredgecolor": "red"},
flierprops = dict(markerfacecolor = '.1', markersize = .0018, linestyle = "none", markeredgecolor='steelblue'),
boxprops=dict(alpha=.7), width=.3)
但是,我有相当多的异常值,这使得箱线图在美学上看起来有点不吸引人;具体来说,我在胡须之外看到了近乎连续的异常值流。不幸的是,我无法为这个示例生成虚构数据,因为它需要在一个本来很大的数据集中有许多异常值才能发生。
我尝试在某种程度上使用异常值的替代颜色来“改进”这一点并减小它们的大小,但并没有太大改善结果。一个效果适中的选项是将 flierprops 中的“linestyle”参数设置为“dotted”。
但是,有没有办法将“抖动”参数传递给 flierprops 字典?有人可以建议一种使异常值抖动的方法吗?
【问题讨论】:
标签: python matplotlib seaborn