0

I have a pandas data frame "data" with four columns age, year, nodes, status. Status being the class/target variable which has only two values 1 - alive and 2- dead.

sns.FacetGrid(data, hue="status", size=5).map(sns.distplot, "year").add_legend();
plt.show();
sns.FacetGrid(data, hue="status", size=5).map(sns.distplot, "age").add_legend();
plt.show();

After executing the above statements in single cell in jupyter, the output will be two plots one after another in a single cell.

I would want to print these plots side by side in a single cell. Please help.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
Avinash
  • 53
  • 5
  • Try [subplots](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.subplots.html) – myz540 Jun 03 '21 at 16:17
  • Does this answer your question? [combine different seaborn facet grids into single plot](https://stackoverflow.com/questions/44158276/combine-different-seaborn-facet-grids-into-single-plot) – Alex Jun 03 '21 at 16:42

1 Answers1

-1

Try running this code!

import matplotlib.pyplot as plt # You would have already imported this

plt.subplot(221)
sns.FacetGrid(data, hue="status", size=5).map(sns.distplot, "year").add_legend();
# plt.show();
plt.subplot(222)
sns.FacetGrid(data, hue="status", size=5).map(sns.distplot, "age").add_legend();
# plt.show(); 

Ideally, the plots should be displayed now. If they don't, uncomment plt.show()