Seaborn stacked histogram/barplot
Just stack the total histogram with the survived -0 one. It's hard to give the exact function without the precise form of the dataframe, but here's a basic example with one of seaborn examples dataset.
import matplotlib.pyplot as plt
import seaborn as sns
tips = sns.load_dataset("tips")
sns.distplot(tips.total_bill, color="gold", kde=False, hist_kws={"alpha": 1})
sns.distplot(tips[tips.sex == "Female"].total_bill, color="blue", kde=False, hist_kws={"alpha":1})
plt.show()
Starting seaborn 0.11.0, you can do this
# stacked histogram
import matplotlib.pyplot as plt
f = plt.figure(figsize=(7,5))
ax = f.add_subplot(1,1,1)
# mock your data frame
import pandas as pd
import numpy as np
_df = pd.DataFrame({
"age":np.random.normal(30,30,1000),
"survived":np.random.randint(0,2,1000)
})
# plot
import seaborn as sns
sns.histplot(data=_df, ax=ax, stat="count", multiple="stack",
x="age", kde=False,
palette="pastel", hue="survived",
element="bars", legend=True)
ax.set_title("Seaborn Stacked Histogram")
ax.set_xlabel("Age")
ax.set_ylabel("Count")