Skip to content

Use savefig instead of print_figure - #9124

Merged
tacaswell merged 2 commits into
matplotlib:masterfrom
anntzer:savefig
Sep 1, 2017
Merged

tacaswell merged 2 commits into
matplotlib:masterfrom
anntzer:savefig

Conversation

@anntzer

@anntzer anntzer commented Aug 30, 2017

Copy link
Copy Markdown
Contributor

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

@dopplershift dopplershift left a comment

Copy link
Copy Markdown
Contributor

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.

ax.set_xlabel('time')
ax.set_ylabel('volts')
canvas.print_figure('test')
fig.savefig('test')

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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