'How to show the mean and 95% confidence interval in Seaborn ecdfplot?

Using seaborn.lineplot is easy to draw a line plot with the mean and 95% confidence interval:

import pandas as pd
import seaborn as sns
sns.set_theme(style="darkgrid")
import matplotlib.pyplot as plt
plt.style.use('ggplot')
flights = sns.load_dataset("flights")
flights.head()

# year  month   passengers
# 0 1949    Jan 112
# 1 1949    Feb 118
# 2 1949    Mar 132
# 3 1949    Apr 129
# 4 1949    May 121
sns.lineplot(data=flights, x="year", y="passengers")

enter image description here

How to do the same shaded effect when plotting a seaborn.ecdfplot?

You could use the following data as an example.

samples = [
        {"pst": 1, "fold": 0},{"pst": 1, "fold": 0},{"pst": 1, "fold": 0},
        {"pst": 2, "fold": 0},{"pst": 2, "fold": 0},
        {"pst": 3, "fold": 0},

        {"pst": 1, "fold": 1},{"pst": 1, "fold": 1},
        {"pst": 2, "fold": 1},{"pst": 2, "fold": 1},{"pst": 2, "fold": 1},
        {"pst": 3, "fold": 1},{"pst": 3, "fold": 1},
]
df = pd.DataFrame(samples)


Sources

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

Source: Stack Overflow

Solution Source