Christopher James
Christopher James

Reputation: 332

seaborn boxplot: Change color and shape of mean

Simple question that I cannot seem to find the answer to.

How do I change the color and shape of the mean indicator in a Seaborn Boxplot?

It defaults to a Green Triangle and it generally difficult to see.

I've tried to find the answer in both the seaborn documentation, as well as the matplotlib documentation. There is also a related question on stackoverflow where someone asked how to change around colors related to the seaborn boxplots and was able to change everything except for the mean indicator.

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

data = [[np.random.rand(100)] for i in range(3)]

sns.boxplot(data=data, showmeans=True)

plt.show()

Seaborn Boxplot

Upvotes: 23

Views: 13947

Answers (1)

DavidG
DavidG

Reputation: 25363

The keyword argument you are looking for is meanprops. It is in the matplotlib boxplot documentation under "other parameters":

import seaborn as sns

data = [[np.random.rand(100)] for i in range(3)]

sns.boxplot(data=data, showmeans=True,
            meanprops={"marker":"s","markerfacecolor":"white", "markeredgecolor":"blue"})

plt.show()

enter image description here

Upvotes: 43

Related Questions