The following:
sns.boxplot(data, x='foo', y='bar', alpha=0.3)
Fails with:
TypeError: boxplot() got an unexpected keyword argument 'alpha'
I presume boxplots don't support alpha or transparency? Or is there any other way of getting it?
The above is using 0.7.0 on Python 3.5.2 (conda install on the default channel)
It's not supported through the seaborn API, but it is through kwargs that are passed down to matplotlib:
ax = sns.boxplot(x='day', y='tip', data=tips, boxprops=dict(alpha=.3))
But this also sets the alpha on the edges of the boxes, which I find aesthetically displeasing. A more roundabout way to grab the patch artists after plotting and then to just change the alpha of the box fills:
ax = sns.boxplot(x='day', y='tip', data=tips)
for patch in ax.artists:
r, g, b, a = patch.get_facecolor()
patch.set_facecolor((r, g, b, .3))
there may be a more direct but less obvious way to do that, usually is in matplotlib.
Fantastic. Thanks @mwaskom !
Most helpful comment
It's not supported through the seaborn API, but it is through kwargs that are passed down to matplotlib:
But this also sets the alpha on the edges of the boxes, which I find aesthetically displeasing. A more roundabout way to grab the patch artists after plotting and then to just change the alpha of the box fills:
there may be a more direct but less obvious way to do that, usually is in matplotlib.