This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Change mean color in seaborn

Hello guys, I'm wondering if have a way to change the mean color in a seaborn graph, for example, the horizontal light grey line inside of each box is the mean, I want to change that color, there is any way to make it?

Another question is: there is any way to change the color of borderlines of the box?

enter image description here

python graph color seaborn

Hi,

Please use a different website (such as imgbb) to host the image. The website you're currently using has certain protective measures that does not allow images to be rendered properly on Biostars.

I put imgbb link now, but for me does not appear any image...

Please see How to add images to a Biostars post to add your images properly. You need the direct link to the image, not the link to the webpage that has the image embedded (which is what you have used here)

Oh sorry RamRS, I think that's right in this time.

No need for the sorry, it's just a bit of a learning curve :-)

Hello flogin!

We believe that this post does not fit the main topic of this site.

The problem was solved

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

Please do not close questions unless there is good reason. You've accepted a solution, that was the right thing to do. There is next to no reason for anyone to close their own post. I've re-opened the post now.

1 answer

seaborn returns a matplotlib.axes object which you can manipulate just like any other matplotlib object,

import matplotlib.pyplot as plt
ax = sns.boxplot(x=your_data)
# getp shows you all the properties of an axes object
plt.getp(ax)

You can then use plt.setp to manipulate all properties, but it's easier to do this:

Since it's a fancier version of a matplotlib.boxplot, you can also use the same arguments:

ax = sns.boxplot(x=your_data,medianprops={'color':'red'})

will give you a red line for the median, you can also change the box lines:

ax = sns.boxplot(x=tips["total_bill"],medianprops={'color':'red'},boxprops = dict(linestyle='--', linewidth=3, color='darkgoldenrod'))

Here's a gallery with examples: https://matplotlib.org/3.1.0/gallery/statistics/boxplot.html

Thanks, Philipp, I was searching for that customization in seaborn documentation and forgot to view in matplotlib.

Thanks again!

Log in to answer this question.