python - How to Iterate a dictionary of references to matplotlib figures -
i have number of functions each of creates 1 or more figures. figures created, reference added dictionary, so:
self.figures['figurekey'] = figure()
in function, iterate dictionary , save each of figures; nice use dictionary key part or of filename. have been able iterate dictionary figure()
function seems require integer corresponding figure number, rejecting reference given key.
fig in self.figures: figure(self.figures[fig]) #does not work figure(fig) #also not work savefig(fig) #seems let me use key filename--nice
i have attempted use `get_fignums()' , iterate returned array, loses association key names. perhaps possible dereference figure number figure pointer? have slick approach this?
please resist tendency begin answer phrase "why don't just..." answer not obvious approach me. i'm sort of new @ this.
you can figure number figure instance. from docs:
the returned figure objects have number attribute holding number.
so access figure number, this:
figure(self.figures[fig].number)
i don't have matplotlib installed test though.
Comments
Post a Comment