Consider (Assume code runs without error):
import matplotlib.figure as matfig
ind = numpy.arange(N)
width = 0.50;
fig = matfig.Figure(figsize=(16.8, 8.0))
fig.subplots_adjust(left=0.06, right = 0.87)
ax1 = fig.add_subplot(111)
prev_val = None
fig.add_axes(ylabel = 'Percentage(%)',xlabel='Wafers',title=title,xticks=(ind+width/2.0,source_data_frame['WF_ID']))
fig.add_axes(ylim=(70,100))
for key,value in bar_data.items():
ax1.bar(ind,value, width,color='#40699C', bottom=prev_val)
if prev_val:
prev_val = [a+b for (a,b) in zip(prev_val,value)]
else:
prev_val=value
names= []
for i in range(0,len(col_data.columns)):
names.append(col_data.columns[i])
ax1.legend(names,bbox_to_anchor=(1.15, 1.02))
I now want to save my figure with fig.savefig(outputPath, dpi=300), but I get AttributeError: 'NoneType' object has no attribute 'print_figure', because fig.canvas is None. The sub plots should be on the figures canvas, so it shouldn't be None. I think i'm missing a key concept about matplot figures canvas.How can I update fig.canvas to reflect the current Figure, so i can use fig.savefig(outputPath, dpi=300)? Thanks!