Skip to content

Navigation Menu

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

Appearance settings

Suptitle swapping order of updates between defaults and fontdict #27707

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from

Conversation

lcapalleja
Copy link

Closes #27630

PR summary

Issue #27630 highlighted how passing a size value inside fontdict was being ignored within figure.suptitle. This was happening because the default kwargs sent to Text were being updated with the defaults last (i.e. highest priority). Switching the order of the dictionary update fixes this, giving highest priority to arguments specified in fontdict by the user.

Test code by @boffi:

import matplotlib.pyplot as plt

fig = plt.figure(figsize=(8, 3), layout='constrained')
f0, f1 = fig.subfigures(1, 2)
f0.suptitle('xxxXXX', fontdict=dict(family='Candara', size=30))
f0.add_subplot().set_title('xxxXXX', fontdict=dict(family='Candara', size=20))
f1.suptitle('xxxXXX', size=30, fontdict=dict(family='Candara'))
f1.add_subplot().set_title('xxxXXX', size=20, fontdict=dict(family='Candara'))
plt.show()

Broken behavior:
Figure_0

Fixed behavior:
Figure_1

PR checklist

Note: This is my first PR. Please let me know if I messed up anything here.

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 week or so, please leave a new comment below and that should bring it to our attention. 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.

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.

Can you add a test to our test suite to make sure this works and continues to work? Probably in lib/matplotlib/tests//test_figure.py.

@lcapalleja
Copy link
Author

@jklymak, I added a test. Let me know if this needs anything else.

@jklymak
Copy link
Member

jklymak commented Feb 1, 2024

Is it possible to test without an image test by querying the fontsize? We try to minimize image tests, particularly with text, but sometimes it is unavoidable.

@lcapalleja lcapalleja force-pushed the suptitle_fontdict_size_bug branch from 4a78e56 to cd17206 Compare February 6, 2024 18:17
@lcapalleja
Copy link
Author

Is it possible to test without an image test by querying the fontsize? We try to minimize image tests, particularly with text, but sometimes it is unavoidable.

@jklymak, made this change. Thank you for the guidance!

@QuLogic
Copy link
Member

QuLogic commented Mar 21, 2024

The new test does not appear to be passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs review
Development

Successfully merging this pull request may close these issues.

[Bug]: Inconsistency in fig.suptitle treatment of size=...
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.