| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| @image_comparison(['transparent_background'], | ||
| extensions=['png'], savefig_kwarg={'transparent': True}, | ||
| remove_text=True) | ||
| def test_savefig_transparent(): |
There was a problem hiding this comment.
@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?
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, but it's extremely unlikely that we'd ever introduce a bug such that ax.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 axes manually made transparent with set_facecolor("none") calls.
Sorry, something went wrong.
There was a problem hiding this comment.
Ah okay. Yeah, I'll do that then. Thanks.
Sorry, something went wrong.
There was a problem hiding this comment.
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 with check_figures_equal?
Sorry, something went wrong.
There was a problem hiding this comment.
@anntzer any suggestions on this?
Sorry, something went wrong.
There was a problem hiding this comment.
Something like
@mpl.rc_context({"savefig.transparent": True})
@check_figures_equal(extensions=["png"])
def test_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])
for ax in [ax12, ax1, iax1, iax2, ax2, ax3]:
ax.set(xticks=[], yticks=[])
ax.spines[:].set_visible(False)
# and draw nothing on fig_ref.?
Sorry, something went wrong.
There was a problem hiding this comment.
Did not know about mpl.rc_context. This should work, thanks!
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
@chahak13 you could add the original author as a co-author in the single commit: |
Sorry, something went wrong.
|
This appears to need a rebase to get the docs build working. |
Sorry, something went wrong.
Co-authored-by: Shreeya Ramesh <shreeyar@umich.edu> Co-authored-by: Chahak Mehta <chahakmehta013@gmail.com>
Conflict was caused by the new test being right above the test from matplotlib#24816, which is not in the v3.7.x branch. FIX: use locators in adjust_bbox (cherry picked from commit 8ef978d)
| Back | FazBrowse Home | New Git URL |
PR Summary
This is a continuation on #22816 to make sure savefig(..., 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
Release Notes