-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use savefig instead of print_figure #9124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Leaving open just a little while longer to make sure no one wants to speak up.
@@ -17,4 +17,4 @@ | |||
ax.grid(True) | |||
ax.set_xlabel('time') | |||
ax.set_ylabel('volts') | |||
canvas.print_figure('test') | |||
fig.savefig('test') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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