I want to create a plot showing both the real data and a smoothed version of the data. Now, I am using the following script:
import pandas as pd
import matplotlib.pyplot as plt
# DataFrame of 321 values
df = pd.read_csv('data.csv')
r = df.rolling(window=10, center=True, on='Value').mean()
fig = plt.figure()
ax = df['Value'].plot(style='--', c='b', alpha=0.5)
r.plot(ax=ax, legend=0, c='b')
plt.show()
However, I would like this to work similarly to e.g. TensorBoard
. There, you specify a smoothing parameter between 0
and 1
which changes the window of the rolling mean, 0
being no smoothing and 1
being extreme smoothing. How is this done? Can I also do this in Python?