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

Skip to content

Fix offset legend tightbbox #17511

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
May 28, 2020

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented May 26, 2020

PR Summary

Closes #10194

legend, if it receives a "None" for bbox_transform positions the legend relative to its parent.bbox, which usually works fine, but if you mess with the transFigure, as we do when bbox_inches='tight' is called, then the new transFigure is not used (everything is still relative to the bbox of the figure, which doesn't change).

This tiny change just sets a default transform for figure legends to be the figure's transform.

and adds a test...

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

@jklymak jklymak force-pushed the fix-offset-legend-tightbbox branch from f3e92c8 to a4922fe Compare May 26, 2020 14:09
@jklymak jklymak added this to the v3.3.0 milestone May 26, 2020
@jklymak
Copy link
Member Author

jklymak commented May 26, 2020

This fixes pretty old bug marked as 3.3, so marking 3.3. But feel free to push forward to 3.4

@QuLogic
Copy link
Member

QuLogic commented May 26, 2020

It looks like a different test might have broken?

@jklymak
Copy link
Member Author

jklymak commented May 26, 2020

Lots broke! I guess thats helpful, because I'm curious why...

@jklymak jklymak force-pushed the fix-offset-legend-tightbbox branch from 479036d to 7adfd90 Compare May 26, 2020 23:26
@jklymak
Copy link
Member Author

jklymak commented May 26, 2020

breakage was trivial: There was a test for the arguments legend was being called with, and since we are explicitly passing bbox_transform we need to include it in that list.

@jklymak jklymak force-pushed the fix-offset-legend-tightbbox branch from 7adfd90 to b71691a Compare May 26, 2020 23:28
@jklymak jklymak removed the request for review from ImportanceOfBeingErnest May 27, 2020 02:17
@tacaswell tacaswell merged commit a5a4324 into matplotlib:master May 28, 2020
@jklymak jklymak deleted the fix-offset-legend-tightbbox branch May 28, 2020 02:23
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.

legend is not present in the generated image if I use 'tight' for bbox_inches
3 participants