I want to draw the following box-plot with white face color overlaid on a violin plot and swarmplot, something similar to the following plot:
This is the following code that I was trying:
ax = sns.violinplot(x="variable",
y="value",
data=pd.melt(box_plot_df),
inner=None,
width=0.9,
edgecolor="black",
scale="width",
palette="Set1")
border_colors = ["red", "blue"]
# Set transparancy for all violins
for i in range(len(ax.collections)):
ax.collections[i].set_alpha(0.4)
ax.collections[i].set_edgecolor(border_colors[i])
ax = sns.boxplot(x="variable",
y="value",
width= 0.3,
medianprops={"color": "black", "linewidth" :2, "linestyle" : "--"},
boxprops={'facecolor': 'white'},
data=pd.melt(box_plot_df),
)
for patch in ax.patches:
r, g, b, a = patch.get_facecolor()
patch.set_facecolor((1.0, 1.0, 1.0, 1.0))
ax = sns.swarmplot(x="variable",
y="value",
hue=None,
data=pd.melt(box_plot_df),
palette="Set1",
size=5,
marker="o")
I was getting the following output:
I was struggling to get the absolutely white face-color for each box. I am not sure, why I am not getting an absolute white color.

