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]: Make inset axes transparent on savefig(..., transparent=True)#24816

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

Merged
ksunden merged 1 commit intomatplotlib:mainfromchahak13:transparent_inset_axes
Jan 26, 2023

Conversation

chahak13
Copy link
Contributor

PR Summary

This is a continuation on#22816 to make suresavefig(..., transparent=True) handles nested figures and axes. Also updates the test figure to include doubly-nested cases to test against.

Closes issue#22674

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (andpytest passes)
  • [n/a] Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • [n/a] New plotting related features are documented with examples.

Release Notes

  • New features are marked with a.. versionadded:: directive in the docstring and documented indoc/users/next_whats_new/
  • API changes are marked with a.. versionchanged:: directive in the docstring and documented indoc/api/next_api_changes/
  • Release notes conform with instructions innext_whats_new/README.rst ornext_api_changes/README.rst

@image_comparison(['transparent_background'],
extensions=['png'], savefig_kwarg={'transparent': True},
remove_text=True)
def test_savefig_transparent():
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@anntzer one reason I did not implement the complete empty plot test mentioned in the previous PR was that that test would pass even if there is nothing being done while plotting?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but it's extremely unlikely that we'd ever introduce a bug such thatax.spines[:].set_visible(False); ax.set(xticks=[], yticks=[]) would actually disable all drawing.
If you want to feel extra safe I would still do a check_figures_equal where the reference figure has all axesmanually made transparent with set_facecolor("none") calls.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ah okay. Yeah, I'll do that then. Thanks.

Copy link
ContributorAuthor

@chahak13chahak13Dec 30, 2022
edited
Loading

Choose a reason for hiding this comment

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

I had a quick question. Since this is related to a savefig parameter, I'll need to pass that to the savefig function inside the decorator. From what I can see, that's not possible right now withcheck_figures_equal?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@anntzer any suggestions on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like

@mpl.rc_context({"savefig.transparent":True})@check_figures_equal(extensions=["png"])deftest_savefig_transparent(fig_test,fig_ref):# create two transparent subfigures with corresponding transparent inset# axes. the entire background of the image should be transparent.gs1=fig_test.add_gridspec(3,3,left=0.05,wspace=0.05)f1=fig_test.add_subfigure(gs1[:, :])f2=f1.add_subfigure(gs1[0,0])ax12=f2.add_subplot(gs1[:, :])ax1=f1.add_subplot(gs1[:-1, :])iax1=ax1.inset_axes([.1,.2,.3,.4])iax2=iax1.inset_axes([.1,.2,.3,.4])ax2=fig_test.add_subplot(gs1[-1, :-1])ax3=fig_test.add_subplot(gs1[-1,-1])foraxin [ax12,ax1,iax1,iax2,ax2,ax3]:ax.set(xticks=[],yticks=[])ax.spines[:].set_visible(False)# and draw nothing on fig_ref.

?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Did not know aboutmpl.rc_context. This should work, thanks!

@chahak13
Copy link
ContributorAuthor

chahak13 commentedDec 26, 2022
edited
Loading

PR cleanliness check is failing because of the test file being changed. I can squash all of it and force push but will that remove the original author's commit info since there's only one commit? I don't want to do that ideally.

@rcomer
Copy link
Member

@chahak13 you could add the original author as a co-author in the single commit:
https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors

chahak13 reacted with thumbs up emoji

@QuLogic
Copy link
Member

This appears to need a rebase to get the docs build working.

Co-authored-by: Shreeya Ramesh <shreeyar@umich.edu>Co-authored-by: Chahak Mehta <chahakmehta013@gmail.com>
@ksundenksunden merged commit13a6ecf intomatplotlib:mainJan 26, 2023
rcomer pushed a commit to rcomer/matplotlib that referenced this pull requestMar 21, 2023
Conflict was caused by the new test being right above the test frommatplotlib#24816, which is not in the v3.7.x branch.FIX: use locators in adjust_bbox(cherry picked from commit8ef978d)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer left review comments

@tacaswelltacaswelltacaswell approved these changes

@ksundenksundenksunden approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.8.0
Development

Successfully merging this pull request may close these issues.

7 participants
@chahak13@rcomer@QuLogic@tacaswell@anntzer@ksunden@sramesh750

[8]ページ先頭

©2009-2025 Movatter.jp