I am trying to plot how many daily events of each category happened, together with a 7 days rolling average of the total. Concretely my data has the shape:
data = {
'Category A': np.random.randint(1, 10, 10),
'Category B': np.random.randint(1, 10, 10),
}
df = pd.DataFrame(data, index=date_range)
adding the rolling average:
df['total'] = df.sum(axis=1)
df['rolling'] = df['total'].rolling(window=7).mean()```
Then I thought I could simply do
```ax = df[['Category A', 'Category B']].plot(kind='bar', stacked=True)
df['rolling'].plot(kind='line', ax=ax)
However, I can only see the second plot. Is there a way to add one on top of each other, without overwriting the first? alpha
does not seem to help here.