I realized there are different color styles used for subplots that all are built upon the seaborn library (check the picture).
Anyone knows how to get the same ...
- edgecolor,
- transparency of the filling and
- filling color ...
for sns.boxenplot, sns.boxplot and sns.histplot?
This is my code:
import seaborn as sns
sns.set(style='whitegrid')
sns.set_palette('pastel')
def boxenplot_boxplot_histo(data, feature, bins = None):
# Create a figure and three subplots
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, sharex=True, figsize=(7,4))
# Subplot 1: Boxen Plot
sns.boxenplot(data=data, x=feature, ax=ax1)
# Subplot 2: Box Plot
sns.boxplot(data=data, x=feature, ax=ax2)
# Subplot 3: Histogram
sns.histplot(data, x=feature, ax=ax3, bins=10, edgecolor='darkgrey')
plt.show()
data = sns.load_dataset("tips")
boxenplot_boxplot_histo(data, 'total_bill')
I tried using the saturation parameter for both the boxenplot and boxplot --> but that parameter is not available for the histplot.
# Subplot 1: Boxen Plot
sns.boxenplot(data=data, x=feature, ax=ax1, saturation=1)
# Subplot 2: Box Plot
sns.boxplot(data=data, x=feature, ax=ax2, saturation=1)
also tried make configurations with the boxprops parameter for the boxplot but again, that's not available for sns.boxenplot.
sns.boxenplot(data=data, x=feature, ax=ax1, saturation=1, boxprops=dict(alpha=0.75))
These functions have slightly different parameterizations and defaults but here's how you can make them look more consistent:
The main thing is that the color is slightly desaturated by default in
boxenplot
andboxplot
, whereas is it slightly transparent inhistplot
.