python - 使用 matplotlib 在箱线图中显示传单颜色

标签 python matplotlib statistics boxplot

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

默认情况下,绘制空圆。可以设置面部颜色,as shown in the example .尽管如此,圆形边框始终是一条黑线。我尝试使用 colormarkercolor 键(前者无效,后者产生错误)。

如何设置标记线的颜色?

最佳答案

要设置标记颜色,请使用属性 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 字典,就像其他箱线图属性一样:http://matplotlib.org/users/dflt_style_changes.html?highlight=flierprops#boxplot

关于python - 使用 matplotlib 在箱线图中显示传单颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43342564/

相关文章:

python - matplotlib 刻度标签不起作用

python - 数据可视化: Matplotlib and Numpy throwing value error

python - 为什么 beta 分布的值在 [0, 1] 之外?

python - 前端和后端之间的内存使用差异很大(而且很奇怪)

python - 在 Python 中加入 2 个不同大小的列表

numpy - 解释散点图的 np.polyfit 和 np.polyval

java - 统计查询

language-agnostic - 模拟 10,000 个滑槽和梯子游戏的最易读的编程语言?

python - 截断日期时间对象 pandas

python - 计算 Django 中模型属性的总和