Why Is Seaborn Barplot Desaturating Colors?
I am trying to make plots in Python using several different libraries (bokeh, seaborn and matlotlib), but keeping the same color scheme. I have chosen categorical pallete from boke
Solution 1:
Seaborn barplot sets the saturation of the bar face colors to 0.75 by default. This can be overridden by adding saturation=1
to the barplot call.
import pandas as pd
from matplotlib import pyplot as plt
import seaborn as sns
source = pd.DataFrame({'names': ['exp_1', 'exp_2'], 'data':[3, 5]})
fig, ax = plt.subplots(1, 2)
# default saruration setting
sns.barplot(x="names", y="data", data=source, ax=ax[0])
ax[0].set_title('default saturation')
# additional parameter `saturation=1` passed to barplot
sns.barplot(x="names", y="data", data=source, saturation=1, ax=ax[1])
ax[1].set_title('saturation=1')
(This answer is straight form the comment by @JohanC, I'm just elevating it to an answer ... happy for ownership to go to that user.)
Post a Comment for "Why Is Seaborn Barplot Desaturating Colors?"