Skip to content

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

Merged
merged 2 commits into from
Feb 21, 2023

Conversation

robrighter
Copy link
Contributor

@robrighter robrighter commented Feb 19, 2023

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

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

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

Copy link

@github-actions github-actions bot left a 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.

@robrighter robrighter changed the title added test for issue 24910 Fix for issue #24910 Feb 19, 2023
@jklymak
Copy link
Member

jklymak commented Feb 19, 2023

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

@robrighter robrighter marked this pull request as ready for review February 19, 2023 15:22
@robrighter
Copy link
Contributor Author

robrighter commented Feb 19, 2023

@jklymak Thanks for the feedback. I think I have everything ready for review now.

There is a failing linting check for eslint. I was unsure how to resolve it because I do not see a way to reproduce it locally.

edit: The eslint failure is because of this known issue with the tool: #25251

@robrighter robrighter changed the title Fix for issue #24910 Make default facecolor for subfigures be transparent ("none"). Fix for issue #24910 Feb 19, 2023
facecolor : default: :rc:`figure.facecolor`
The figure patch face color.
facecolor : default: ``"none"``
Transparent face color.
Copy link
Member

@rcomer rcomer Feb 20, 2023

Choose a reason for hiding this comment

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

Suggested change
Transparent face color.
The figure patch face color; transparent by default.

or similar. The point is that any color could be passed.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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!

@@ -287,6 +287,16 @@ def test_suptitle_fontproperties():
assert txt.get_weight() == fps.get_weight()


@image_comparison(['figure_suptitle_subfigures'],
extensions=['png'])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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!

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@rcomer rcomer linked an issue Feb 20, 2023 that may be closed by this pull request
@robrighter robrighter force-pushed the bugfix-for-issue-24910 branch from 93009ae to 775ad94 Compare February 20, 2023 20:54
Copy link
Member

@jklymak jklymak left a 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...

@@ -287,6 +287,16 @@ def test_suptitle_fontproperties():
assert txt.get_weight() == fps.get_weight()


@image_comparison(['figure_suptitle_subfigures'],
extensions=['png'], style='mpl20')
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.)

@jklymak
Copy link
Member

jklymak commented Feb 21, 2023

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.

@robrighter robrighter force-pushed the bugfix-for-issue-24910 branch from a20c16b to b82dc38 Compare February 21, 2023 01:55
@robrighter robrighter force-pushed the bugfix-for-issue-24910 branch from b82dc38 to 9d827a8 Compare February 21, 2023 11:59
@rcomer
Copy link
Member

rcomer commented Feb 21, 2023

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?

@jklymak jklymak added this to the v3.8.0 milestone Feb 21, 2023
@jklymak jklymak merged commit c13683a into matplotlib:main Feb 21, 2023
@jklymak
Copy link
Member

jklymak commented Feb 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Suptitle not visible with subfigures
3 participants