Repository navigation
Use savefig instead of print_figure - #9124
Conversation
dopplershift
left a comment
There was a problem hiding this comment.
LGTM. Leaving open just a little while longer to make sure no one wants to speak up.
| ax.set_xlabel('time') | ||
| ax.set_ylabel('volts') | ||
| canvas.print_figure('test') | ||
| fig.savefig('test') |
There was a problem hiding this comment.
this line now makes it unclear as to why canvas was in the example, so maybe now that line should be cut?
There was a problem hiding this comment.
In order for it to work (without the pyplot interface), IIRC you need to create the FigureCanvas instance manually.
There was a problem hiding this comment.
Yup, you're right. I think that's even more reason to add a line/comment explaining that though since it's now sorta weirdly implicit since the canvas is created but not referenced.
There was a problem hiding this comment.
@story645 raises a good point, though: this is an example, so it should be helping the user to understand what is needed, and what is going on. As it stands, it's baffling. Is it necessary to retain the reference to the canvas? If not, that variable should not be created, and a comment should be added to the effect that instantiating FigureCanvas adds a reference to the newly-created canvas to fig, which is all that is needed.
There was a problem hiding this comment.
Good point, edited accordingly.
As explained in the discussion of #9080, savefig and print_figure should ultimately be equivalent, but right now savefig handles transparency better, so use it instead of print_figure.
PR Summary
PR Checklist