根据documentation , Axes.boxplot
函数采用字典 flierprop
作为参数来定义异常值的属性。不幸的是,我找不到关于这本词典的文档。特别是,我想定义标记边框的颜色。
默认情况下,绘制空圆。可以设置面部颜色,as shown in the example .尽管如此,圆形边框始终是一条黑线。我尝试使用 color
和 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
关于python - 使用 matplotlib 在箱线图中显示传单颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43342564/