Skip to content

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

Merged
merged 2 commits into from
Sep 1, 2017
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Aug 30, 2017

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

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Aug 30, 2017
@anntzer anntzer mentioned this pull request Aug 30, 2017
6 tasks
Copy link
Contributor

@dopplershift dopplershift left a 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')
Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, edited accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants