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 change the color of box of boxplot in base R, we can use col argument inside boxplot function.
fliers : points representing data that extend beyond the whiskers (fliers). means : points or lines representing the means.
You can change the color of a box plot using setp on the returned value from boxplot (). This example defines a box_plot () function that allows the edge and fill colors to be specified: import matplotlib.pyplot as plt def box_plot (data, edge_color, fill_color): bp = ax.boxplot (data, patch_artist=True) for element in ['boxes', 'whiskers', ...
For now, unfortunately, matplotlib has rather limited functionality for this purpose. Moreover, there is no unique approach for different types of plots. In this article, we’re going to explore how to add patterns to bar plots, histograms, box plots, and pie charts.
Box Plot in Python using Matplotlib Last Updated : 30 Apr, 2020 A Box Plot is also known as Whisker plot is created to display the summary of the set of data values having properties like minimum, first quartile, median, third quartile and maximum.
That dictionary has the following keys (assuming vertical boxplots): boxes: the main body of the boxplot showing the quartiles and the median’s confidence intervals if enabled. medians: horizontal lines at the median of each box. whiskers: the vertical lines extending to the most end, non-outlier data points.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With