Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seaborn Boxplot with Same Color for All Boxes

I am using seaborn and want to generate a box plot where all boxes have the same color. For some reason seaborn uses different colors for each box and doesn't have an option to stop this behavior and set the same color for all boxes.

How can I force seaborn to use the same color for all boxes?

fig, ax = plt.subplots(figsize=(10, 20))
sns.boxplot(y='categorical_var', x='numeric_var', ax=ax)
like image 911
Chris Avatar asked Jan 05 '23 04:01

Chris


1 Answers

Use the color parameter:

import seaborn as sns
tips = sns.load_dataset("tips")
sns.boxplot(x="day", y="tip", data=tips, color="seagreen")

enter image description here

like image 131
mwaskom Avatar answered Jan 11 '23 12:01

mwaskom