Skip to content
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

ENH: Added __repr__ for Figure #9379

Merged
merged 2 commits into from Nov 11, 2017

Conversation

richardjgowers
Copy link
Contributor

PR Summary

Adds a better repr to Figure
Eg:

<Figure size 640x480 with 2 axes>

(Maybe) Fixes Issue #9372

Anything else that should go into the repr? Maybe dpi?

Could also do __str__ == __repr__ seeing as they're nearly identical?

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

clsname=self.__class__.__name__,
h=self.bbox.size[0], w=self.bbox.size[1],
naxes=len(self.axes),
ax_plural='is' if len(self.axes) == 1 else 'es'
Copy link
Contributor

Choose a reason for hiding this comment

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

The singular of Axes is Axes (... for matplotlib, Axis is something completely different (sad but true)).
TBH I would just have the suptitle and be done with it.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think just saying "with one axes" is probably fine and technically more accurate, would it be possible to change that @richardjgowers ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dstansby ok I've changed this

@dstansby dstansby added this to the v2.2 milestone Oct 17, 2017
@@ -273,6 +273,13 @@ class Figure(Artist):
def __str__(self):
return "Figure(%gx%g)" % tuple(self.bbox.size)

def __repr__(self):
return "<{clsname} size {h:g}x{w:g} with {naxes} axes>".format(
Copy link
Member

Choose a reason for hiding this comment

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

Capital Axes, though, referring to the class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@QuLogic QuLogic merged commit 6a9eac5 into matplotlib:master Nov 11, 2017
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
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.

None yet

4 participants