-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: savefig)...,transparent=True) now makes inset_axes transparent a… #22816
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
Closed
+33
−1
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+4.84 KB
lib/matplotlib/tests/baseline_images/test_figure/transparent_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -557,6 +557,24 @@ def test_savefig_pixel_ratio(backend): | |
assert ratio1 == ratio2 | ||
|
||
|
||
@image_comparison(['transparent_background'], | ||
extensions=['png'], savefig_kwarg={'transparent': True}, | ||
remove_text=True) | ||
def test_savefig_transparent(): | ||
# create two transparent subfigures with corresponding transparent inset | ||
# axes. the entire background of the image should be transparent. | ||
fig = plt.gcf() | ||
gs = fig.add_gridspec(3, 3) | ||
fig.add_subfigure(gs[0, 0]) | ||
fig.add_subplot(gs[0, 0]) | ||
ax = plt.gca() | ||
ax.inset_axes([.1, .2, .3, .4]) | ||
fig.add_subfigure(gs[0:2, 1]) | ||
fig.add_subplot(gs[0:2, 1]) | ||
ax2 = plt.gca() | ||
ax2.inset_axes([.1, .2, .3, .4]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can add |
||
|
||
|
||
def test_figure_repr(): | ||
fig = plt.figure(figsize=(10, 20), dpi=10) | ||
assert repr(fig) == "<Figure size 100x200 with 0 Axes>" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subfigures can be nested arbitrarily; this only handles one level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think another issue was supposed to be opened to handle this general case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nesting should be handled here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tacaswell noted how to do this recursively here #22816 (comment)
This could also be done with a stack approach:
On a side note (and not for this PR), I wonder if we want some kind of
self.iter_subfigures
or similar that would do the above iteration with a callable.