根据文档 https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.boxplot.html#matplotlib.axes.Axes.boxplot, the Axes.boxplot
函数需要一个字典flierprop
作为定义异常值属性的参数。不幸的是,我找不到有关这本词典的文档。特别是,我想定义标记边框的颜色。
默认情况下,绘制空圆圈。可以设置脸部颜色,如示例所示 https://matplotlib.org/examples/statistics/boxplot_demo.html。尽管如此,圆形边框始终是一条黑线。我尝试用钥匙color
and markercolor
(前者没有效果,后者产生错误)。
我应该如何设置标记线的颜色?
设置标记颜色使用属性markerfacecolor
但对于边框颜色 -markeredgecolor
:
import matplotlib.pyplot as plt
import numpy as np
# fake up some data
spread = np.random.rand(50) * 100
center = np.ones(25) * 50
flier_high = np.random.rand(10) * 100 + 100
flier_low = np.random.rand(10) * -100
data = np.concatenate((spread, center, flier_high, flier_low), 0)
# plot. Set color of marker edge
flierprops = dict(marker='o', markerfacecolor='r', markersize=12,
linestyle='none', markeredgecolor='g')
plt.boxplot(data, flierprops=flierprops)
plt.show()
根据@Spiros,flierprops字典像其他箱线图属性一样记录在这里:http://matplotlib.org/users/dflt_style_changes.html?highlight=flierprops#boxplot http://matplotlib.org/users/dflt_style_changes.html?highlight=flierprops#boxplot
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)