带有matplotlib的boxplot中的飞行物颜色

时间:2017-04-11 09:53:39

标签: python matplotlib statistics boxplot

根据documentationAxes.boxplot函数将字典flierprop作为参数来定义异常值的属性。不幸的是,我找不到关于这本词典的文档。特别是,我想定义标记边框的颜色。

默认情况下,会绘制空心圆圈。可以设置面部颜色as shown in the example。然而,圆形边界始终是黑线。我尝试使用密钥colormarkercolor(前者无效,后者产生错误)。

如何设置标记线的颜色?

1 个答案:

答案 0 :(得分:9)

要设置标记颜色使用属性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()

enter image description here

根据@Spiros,flierprops字典在此处记录为与其他boxplot属性一样:http://matplotlib.org/users/dflt_style_changes.html?highlight=flierprops#boxplot