0

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)
Celso França
  • 653
  • 8
  • 31
  • Maybe like [Plot CDF with confidence interval using Seaborn](https://stackoverflow.com/questions/53635064/plot-cdf-with-confidence-interval-using-seaborn)? What kind of data do you want to use? Normally, an ECDF plot uses each given data point exactly once and plots it on its exact position, while with the given line plot for each x-value there are 12 averaged y-positions. – JohanC Feb 23 '22 at 18:56
  • @JohanC unfortunately, the accepted answer in the referred (and similar) question actually did not answer the question since `fill_between` does not show the confidence interval. – Celso França Feb 23 '22 at 23:25

0 Answers0