Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX/ENH: include text in ax.get_tightbbox#10678

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

jklymak
Copy link
Member

@jklymakjklymak commentedMar 4, 2018
edited
Loading

PR Summary

If text overflows an axes,ax.get_tightbbox doesn't include it.

Note this doesn't requireconstrained_layout to be a problem.Saving withbbox_inches='tight' will also cut the extra text off.. EDIT: This wasn't true -bbox_inches='tight' renders the figure and then figures out the bbox. But, I don't see why we wouldn't include over-spilling text in the tight bbox for an axes.

importmatplotlib.pyplotaspltfig,ax=plt.subplots(constrained_layout=True)ax.set_xlim([0,1])ax.text(1,0.5,'This is a long overflow')plt.show()

Before

fig2

After

fig1

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

Copy link
Member

@efiringefiring left a comment

Choose a reason for hiding this comment

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

Looks good, subject to tests passing.

@jklymak
Copy link
MemberAuthor

OK, actually, I'm a little confused now about the API forax.get_tightbbox.

defget_tightbbox(self,renderer,call_axes_locator=True):

It says that it willReturn the tight bounding box of the axes.. It gets its ownwindow_extent and the extent of labels (i.e. titles, and the axises). I addedLegend and someone else addedOffsetBox. However, none of the other artists are part of the bbox. This PR adds text, but none of the other artists.

thetight_bbox forsavefig is implemented in

whereall the artists are iterated through and added to the bbox. I guess I don't see why this functionality isn't moved intoax.get_tightbbox so other functions can take advantage? The only places this function get used (jnternally) istight_layout and_constrained_layout.

Pros: are that dangling artists get counted for layout easily.

Cons: its possible that the user would want the layout to ignore some artists when making a layout.savefig(bbox_inches='tight)actually has another kwarg to take care of this:bbox_extra_artists`.

Comments?

@jklymak
Copy link
MemberAuthor

Closing in lieu of#10682, which I think is a more comprehensive solution.

@jklymakjklymak closed thisMar 5, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@efiringefiringefiring approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@jklymak@efiring

[8]ページ先頭

©2009-2025 Movatter.jp