I'm plotting some data based on pandas dataframes and series. Following is a part of my code. This code gives an error.
RuntimeError: underlying C/C++ object has been deleted
from matplotlib import pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
fig = plt.figure()
dfs = df['col2'].resample('10t', how='count')
dfs.plot()
plt.show()
reg = df.groupby('col1').size()
reg.sort()
reg[-10:].plot(kind='barh')
plt.show()
pp = PdfPages('foo.pdf')
fig.savefig(pp, format='pdf')
pp.close()
I have two questions.
- How to plot multiple plots in one output?(Here I get multiple outputs for each and every plot)
- How to write all these plots in to one pdf?
I found this as a related question.