使用matplotlib在箱图中的传单颜色 [英] Flier colors in boxplot with matplotlib

查看:152
本文介绍了使用matplotlib在箱图中的传单颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据



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


According to the documentation, the Axes.boxplot function takes a dictionary flierprop as argument to define the properties of the outliers. Unfortunately, I can't find the documentation concerning this dictionary. In particular, I would like to define the color of the border of the marker.

By default, empty circles are drawn. One can set the face color, as shown in the example. Nevertheless, the circle border is always a black line. I tried with the keys color and markercolor (the former has no effect, the latter produces an error).

What should I do to set a color for the marker line?

解决方案

To set marker color use property markerfacecolor but for border color - 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()

According to @Spiros the flierprops dictionary is documented here like other boxplot properties: http://matplotlib.org/users/dflt_style_changes.html?highlight=flierprops#boxplot

这篇关于使用matplotlib在箱图中的传单颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆