10000 Remove unnecessary Legend._approx_text_height. by anntzer · Pull Request #16312 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Remove unnecessary Legend._approx_text_height. #16312

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

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Jan 23, 2020

It is only ever called with renderer=None, returning the fontsize
directly. In fact the rest of the code assumes that the font size is
in points (inch/72), not in pixels. This can be checked by setting the
dpi to a large value (e.g. 500), forcing the renderer to be not None by
adding renderer = self.figure.canvas._cachedRenderer and making sure
that a cached renderer exists (via fig.canvas.draw()) before creating
the legend -- such a patch results in a highly distorted legend layout,
whereas just using fontsize is fine even at high dpi.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 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

It is only ever called with renderer=None, returning the fontsize
directly.  In fact the rest of the code assumes that the font size is
in points (inch/72), not in pixels.  This can be checked by setting the
dpi to a large value (e.g. 500), forcing the renderer to be not None by
adding `renderer = self.figure.canvas._cachedRenderer` and making sure
that a cached renderer exists (via `fig.canvas.draw()`) before creating
the legend -- such a patch results in a highly distorted legend layout,
whereas just using fontsize is fine even at high dpi.
@anntzer
Copy link
Contributor Author
anntzer commented Jan 24, 2020

good to go?

@ImportanceOfBeingErnest
Copy link
Member

I would have expected this change to cause image test failures, or is the else branch never hit?

@anntzer
Copy link
Contributor Author
anntzer commented Jan 24, 2020

It is never hit, as explained above.

@ImportanceOfBeingErnest ImportanceOfBeingErnest merged commit 39301db into matplotlib:master Jan 24, 2020
@anntzer anntzer deleted the legend-text-height branch January 24, 2020 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0