-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make default facecolor for subfigures be transparent ("none"). Fix for issue #24910 #25255
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
Conversation
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
This seems good. Perhaps add a change note, and also please include some description in the PR... It's possible your image comparison fails because the wrong version of freetype? https://matplotlib.org/stable/devel/dependencies.html#c-libraries |
lib/matplotlib/figure.py
Outdated
facecolor : default: :rc:`figure.facecolor` | ||
The figure patch face color. | ||
facecolor : default: ``"none"`` | ||
Transparent face color. |
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.
Transparent face color. | |
The figure patch face color; transparent by default. |
or similar. The point is that any color could be passed.
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 you committed this suggestion, but then it got clobbered in the git confusion. Easily done.
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.
You are right. Sorry about that. I amended the commit to add it back in.
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.
No worries - I've done similar!
lib/matplotlib/tests/test_figure.py
Outdated
@@ -287,6 +287,16 @@ def test_suptitle_fontproperties(): | |||
assert txt.get_weight() == fps.get_weight() | |||
|
|||
|
|||
@image_comparison(['figure_suptitle_subfigures'], | |||
extensions=['png']) |
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.
extensions=['png']) | |
extensions=['png'], style='mpl20') |
Not compulsory, but the newer style is preferred. If you decide to change this, the image will also need replacing. Adding and replacing an image in separate commits in the same PR will cause a CI failure, so you would also need to squash the commits down to one. So whether you take this suggestion should depend on how confident you feel with git!
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.
Thanks @rcomer, I made the changes you suggested. I also squashed down the commits to avoid the image change issue in the CI pipeline.
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.
Well, looks like the added-modified check on that image failed. I'll investigate and get it sorted.
93009ae
to
775ad94
Compare
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.
This looks good, but not sure we need a visual test...
lib/matplotlib/tests/test_figure.py
Outdated
@@ -287,6 +287,16 @@ def test_suptitle_fontproperties(): | |||
assert txt.get_weight() == fps.get_weight() | |||
|
|||
|
|||
@image_comparison(['figure_suptitle_subfigures'], | |||
extensions=['png'], style='mpl20') |
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'm not sure we really need a visual test here... It should be enough to check that facecolor="none" for the subfigure by default, no?
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 can see either way. I guess removing the visual test would keep the build time minimal. However, having the visual test provides some protection if another subtle change impacts the way the subfigures can hide the suptitle. If you think that risk is minimal because the behavior is well understood, I'm happy to remove it.
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 suptitle is under the subfigure (if subfigure is called first). There isn't much to be done about that without using a layout manager. So I'd argue either the subfigure has a clear face or it doesn't is all we can test here. If something else ends up in the subfigure that is not clear, then the suptitle will disappear anyway.
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.
Ok I will update the PR to:
(1) Remove the visual test
(2) Add a new test that creates the figure and checks for the default clear face on the subfigures. (And maybe a non-default value test too.)
Note to pass the Cleanliness check you will need to squash the commits. If in doubt about how to do that, suggest you back up to a backup branch. |
a20c16b
to
b82dc38
Compare
b82dc38
to
9d827a8
Compare
Thanks @robrighter, I think this is ready to merge, but... @jklymak I'm not sure what milestone this should go in: from the issue's point of view it's a bugfix, which would normally go in v3.7.1. However, since this changes a default, it's likely to break someone. I understand that's OK to do without warning since subfigures are provisional, but maybe not in a patch release? |
Thanks @robrighter I squashed your commits before merging. Congratulations on your first PR to Matplotlib! @rcomer, I think you are right that this is too big a change for a bug fix release. But I don't feel strongly about it if someone wants to argue for a backport to 3.7.1 |
PR Summary
This issue was written because the solid facecolor on subfigures was hiding the parent figure suptitle. A few solutions were identified and discussed in the issue thread #24910 . It was decided that the best solution is to change the default facecolor value to "none" (transparent). This PR makes that change.
PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst