%matplotlib inline import numpy as np import matplotlib.pyplot as plt plt.rcParams['text.usetex'] = False import pandas import seaborn seaborn.set(style='ticks') N = 370 dt = pandas.offsets.Milli(500) x = np.random.lognormal(size=N) timestamps = pandas.DatetimeIndex(freq=dt, start='2012-01-01', periods=N) fig, (ax1, ax2) = plt.subplots(figsize=(12,4), nrows=2, sharex=True) ts = pandas.TimeSeries(data=x, index=timestamps) tsmean = pandas.expanding_mean(ts, min_periods=5) diff = mean.diff() diffmean = pandas.expanding_mean(diff, min_periods=5) ax = ts.plot(ax=ax1, label='Measurements') tsmean.plot(ax=ax1, label='Expanding Mean') ax1.set_yscale('log') ax1.set_ylabel('Flow velocity (m/s)') ax1.xaxis.tick_top() diff.plot(ax=ax2) diffmean.plot(ax=ax2) ax2.set_ylabel('Diff of mean velocity') ax1.legend(ncol=2, loc='lower right') seaborn.despine(ax=ax1, bottom=True, top=False) seaborn.despine(ax=ax2, bottom=False, top=True)