In seaborn 0.6.0, alpha parameter no longer works with violinplot. Used to work fine with 0.5.1
Example to duplicate:
import seaborn as sns
import matplotlib.pyplot as plt
fig = plt.figure()
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.violinplot(x=tips["total_bill"], alpha=0.1)
plt.show()
Yes, that parameter has been removed. Sorry if it didn't make it into the release notes.
In my application, I'm plotting one violinplot over another to see the degree of overlap. Hence, it would be nice if the ability to control the opacity of the plot is restored.
You can always set the alpha on the PolyCollections objects that are attached to the axes object after plotting.
I will try that and let you know! Thanks
That worked. Thanks. Anyway, could it be added to the next sub-release?
I'd like this argument as well - any reason why this was removed?
I also need this alpha parameter, or at least a code snippet how to set the alpha for the PolyCollections object (didn't find anything on the web)
Hello Michael, any chance you could show us a sample of code to change alpha after violinplots have been created using your method (making changes in PolyCollections)?
(p.s. it would be great if alpha is included back again in the arguments)
Thanks
Has anyone been successsful in doing this?
I am not able to figueout how to use PolyCollections with violinplot - and there's still no description in the documentation.
Hi, I am also having trouble finding out how to access the PolyCollections object given the axes object. Would you be able to provide a snippet of example code?
ax.collections
I ended up doing this:
def setAlpha(ax,a):
for art in ax.get_children():
if isinstance(art, PolyCollection):
art.set_alpha(a)
you can just do
plt.setp(ax.collections, alpha=.3)
I'd also like to be able to set this from the violin call..
Most helpful comment
you can just do
plt.setp(ax.collections, alpha=.3)I'd also like to be able to set this from the violin call..