Flier color in box with matplotlib

According to the documentation , the function Axes.boxplottakes a dictionary flierpropas an argument to determine the properties of the outliers. Unfortunately, I can not find the documentation regarding this dictionary. In particular, I would like to determine the color of the border of the marker.

By default, empty circles are drawn. You can set the complexion as shown in the example . However, the circle border is always black. I tried using the keys colorand markercolor(the former has no effect, the latter causes an error).

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

+3
source share
1 answer

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

enter image description here

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

+5
source

Source: https://habr.com/ru/post/1674910/


All Articles