Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am working on a seaborn plot and trying to overlap 2 plots on the jupyter notebook. The code which is shown below works fine when I run it on the python shell but the same code is not working on jupyter. When I run the code on jupyter I get only one plot another plot is not shown. 

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()

1 Answer

0 votes
by (36.8k points)

I have tested your code on sample data and it works fine to me.

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)

Even when I remove the ax=ax it works, I wonder is it the same to you too. Try it, I hope this will work.

Improve your knowledge in data science from scratch using Data Science tutorial 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...