Considerate (Si supponga codice viene eseguito senza errori):Impossibile salvare matplotlib.figure figura, tela è None
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))
io ora voglio salvare la mia figura con fig.savefig(outputPath, dpi=300)
, ma ho AttributeError: 'NoneType' object has no attribute 'print_figure'
, perché fig.canvas
vale None. Le trame secondarie dovrebbero trovarsi sulla tela delle figure, quindi non dovrebbe essere None. Penso che mi manchi un concetto chiave riguardo le figure matplot. Come posso aggiornare fig.canvas in modo che rifletta la figura attuale, quindi posso usare fig.savefig(outputPath, dpi=300)
? Grazie!
Grazie ha un senso! – TheoretiCAL