mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.52k stars 1.92k forks source link

lineplot error bands for timeseries data #1841

Closed darkdragon-001 closed 5 years ago

darkdragon-001 commented 5 years ago

I would like to use lineplot with its nice error bands.Unfortunately this only works when multiple data points are at the same x position. I often have measured timeseries data, so x is increasing slowly and never the same.

Currently, I worked around this problem by using panda's df.rolling():

# moving average
rolling = df['y'].rolling(30, center=True)
ma = rolling.mean()
plt.plot(df['x'], ma, linewidth=2)
# standard derivation bands
mstd = rolling.std()
plt.fill_between(df['x'], ma-2*mstd, ma+2*mstd, alpha=0.2)

It would be nice, if you could add a parameter to lineplot() which mimics this behavior.

mwaskom commented 5 years ago

Thanks for the suggestion but this is unlikely to integrate well into the current code so I am going to pass.