Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Shorten tight_bbox. #17992

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 1 commit into from
Jul 21, 2020
Merged

Shorten tight_bbox. #17992

merged 1 commit into from
Jul 21, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jul 21, 2020

It's more readable to directly define the relevant callbacks
(axes_locator, apply_aspect) as one-line lambdas at the point of use,
instead of having to define them much earlier. Pickling is not an issue
as these lambdas are only set temporarily while computing the figure
tightbbox for saving.

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/next_api_changes/* if API changed in a backward-incompatible way

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

This is better. Would be even better w/ a bit of a comment, because it still looks a bit mystifying.

@QuLogic
Copy link
Member

QuLogic commented Jul 21, 2020

Is the docstring okay instead of a comment? Not sure what part you're referring to.

@anntzer
Copy link
Contributor Author

anntzer commented Jul 21, 2020

I guess @jklymak is hoping for more comments, but let's leave that for another time :)

@jklymak
Copy link
Member

jklymak commented Jul 21, 2020

I find

         _pos = ax.get_position(original=False).frozen()
         ax.set_axes_locator(lambda a, r, _pos=_pos: _pos)

to be pretty obscure and self-referential...

@anntzer
Copy link
Contributor Author

anntzer commented Jul 21, 2020

It's basically the same as before the PR?

It's more readable to directly define the relevant callbacks
(axes_locator, apply_aspect) as one-line lambdas at the point of use,
instead of having to define them much earlier.  Pickling is not an issue
as these lambdas are only set temporarily while computing the figure
tightbbox for saving.
@QuLogic QuLogic added this to the v3.4.0 milestone Jul 21, 2020
@QuLogic QuLogic merged commit 86f1ea7 into matplotlib:master Jul 21, 2020
@anntzer anntzer deleted the tb branch July 21, 2020 22:52
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.

3 participants