'How to plot these graphics side by side? [duplicate]

I have 2 diagrams and they superimposed on one another How can i display them side by side?

sns.histplot(data=dataset.loc[dataset['Survived'] == 0, 'Age'], color='green') \      
 .set(xticks=range(0, 81, 5), title='Survived= 0');

 sns.histplot(data=dataset.loc[dataset['Survived'] == 1, 'Age'], color='purple') \
  .set(xticks=range(0, 81, 5), title='Survived= 1');


Solution 1:[1]

You can instantiate a figure object with two columns and pass the individual columns as ax keyword-arguments to sns.histplot, like so:

dataset = sns.load_dataset('titanic')

fig, ax = plt.subplots(ncols=2)

sns.histplot(data=dataset.loc[dataset['survived'] == 0, 'age'], color='green', ax=ax[0]).set(xticks=range(0, 81, 5), title='Survived= 0');

sns.histplot(data=dataset.loc[dataset['survived'] == 1, 'age'], color='purple', ax=ax[1]).set(xticks=range(0, 81, 5), title='Survived= 1');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 warped