survival_by_age = titanic.groupby(['Age', 'Survived']).size().unstack(
    'Survived')
survival_by_age.columns = ['No', 'Yes']
survival_by_age.plot.bar(title='Survival by Age')
How to create histogram from grouped data