I would like to create one pdf file with 12 plots, in two options:
- one plot per page,
- four plots per page.
Using plt.savefig("months.pdf")
saves only last plot.
MWE:
import pandas as pd
index=pd.date_range('2011-1-1 00:00:00', '2011-12-31 23:50:00', freq='1h')
df=pd.DataFrame(np.random.randn(len(index),3).cumsum(axis=0),columns=['A','B','C'],index=index)
df2 = df.groupby(lambda x: x.month)
for key, group in df2:
group.plot()
I also tried:
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(15, 10))
after the group.plot
but this produced four blank plots...
I have found an example of PdfPages but I don't know how to implement this.