Reputation: 2319
I'm trying to overlay 2 seaborn distplots in jupyter notebook. This code works if I use the normal python shell but doesn't work with Jupyter. I get only one graph. The second graph is not displayed.
import seaborn as sns
import matplotlib.pyplot as plt
from IPython.display import display
%matplotlib inline
sns.set()
sns.distplot(x['wr'], kde=False, label='16-4', hist_kws={"alpha": 0.2})
sns.distplot(y['wr'], kde=False, label='17-4', hist_kws={"alpha": 0.2})
plt.show()
Please don't suggest using the hue
argument.
Upvotes: 1
Views: 1721
Reputation: 169524
I've tested that this works on my sample data:
ax = sns.distplot(x['wr'], kde=False, label='16-4', hist_kws={"alpha": 0.2})
sns.distplot(y['wr'], kde=False, label='17-4', hist_kws={"alpha": 0.2}, ax=ax)
# ^^^^^
But, actually, my code works with or without the ax=ax
; so I'm curious to know if it will work for you.
Upvotes: 1