Change mean color in seaborn
1
0
Entering edit mode
2.3 years ago
flogin ▴ 270

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 • 4.4k views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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)

ADD REPLY
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode

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

ADD REPLY
3
Entering edit mode
2.3 years ago

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

ADD COMMENT
0
Entering edit mode

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

Thanks again!

ADD REPLY

Login before adding your answer.

Traffic: 2369 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6