I'm trying to collect a series of charts in a list then output them all in one run to Excel.
The list shows all the charts as "matplotlib.figure.Figure at (example) 0xb8eae80" but will not display all of them. They all show in the iPython (in Spyder) console when the prog is run.
If I try to show them individually using list[i] in iPython, some charts show but some don't (the same charts are missing).
For the output to Excel, the "missing" charts have a blank canvas of default size so, although XL is getting some info about the existence of a chart, it isn't even getting the "figsize" info.
The missing chart in the example code below is for the chart with multiple line plots (its a quick example, I realise it could be scripted better)
Thanks for any help.
Example code (which has same problem as my original code):
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import xlwings as xw
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
xdf = pd.DataFrame(np.random.randn(1000, 4), index=ts.index, columns=list('ABCD')) # splits out list into components
xdf = xdf.cumsum()
figlist = [] # set up list to collect charts (a list of objects)
fig = plt.figure()
xdf.A.plot(figsize = (9,5), grid=True) #plots individual column
plt.axhline(0,lw=2, color = "black")
plt.title('A')
figlist.append(fig)
fig = plt.figure()
xdf.B.plot(figsize = (9,5), grid=True) #plots individual column
plt.axhline(0,lw=2, color = "black")
plt.title('B')
figlist.append(fig)
fig = plt.figure()
xdf.C.plot(figsize = (9,5), grid=True) #plots individual column
plt.axhline(0,lw=2, color = "black")
plt.title('C')
figlist.append(fig)
fig = plt.figure()
xdf.D.plot(figsize = (9,5), grid=True) #plots individual column
plt.axhline(0,lw=2, color = "black")
plt.title('D')
figlist.append(fig)
fig = plt.figure()
xdf.plot(figsize = (9,5), grid=True) #plots all columns on same chart
plt.axhline(0,lw=2, color = "black")
plt.title('All')
figlist.append(fig)
# output all charts to XL
xw.Workbook() # open new workbook
for i in range(len(figlist)):
plotno = 'Plot' + str(i)
plot = xw.Plot(figlist[i])
plot.show(plotno, left=30, top=(i*500+20))