Skip to content

TST: Use text placeholders for empty legends #29908

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 1 commit into from
Apr 17, 2025

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Apr 12, 2025

PR summary

These tests use remove_text=True and set legend labels to empty strings. However, they are still affected by font metrics because even the empty string is as tall as the line height (which is calculated from the height of the "lp" string.)

This depends on #29907.

PR checklist

@tacaswell
Copy link
Member

👍🏻 now needs a rebase.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Now that text uses placeholders, can we change label=" " to some actual text like label="foo" or label="label"? This feels more normal and may be less confusing when reading the test, or when taking the code and running it without placeholders for debug purposes. The label=" " was only there to reduce the font-rendering impact. I don't see a reason we should keep it.

Copy link
Member

Choose a reason for hiding this comment

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

Why don't the black boxesh show up here like they do in the png?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, it just stopped after the first extension, and I didn't catch it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the mpl20 style doesn't have patch edges, I also decided to remove the forced blue colour on the bars, since they all look like single bars instead of stacked ones.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also reverted the texts here to the values before 966e467

@QuLogic QuLogic force-pushed the legend-placeholders branch 3 times, most recently from 92cd616 to 2053e8c Compare April 15, 2025 03:02
@QuLogic QuLogic force-pushed the legend-placeholders branch from 2053e8c to 6f93bdc Compare April 15, 2025 22:42
These tests use `remove_text=True` and set legend labels to empty
strings. However, they are still affected by font metrics because even
the empty string is as tall as the line height (which is calculated from
the height of the "lp" string.)
@QuLogic QuLogic force-pushed the legend-placeholders branch from 6f93bdc to 7cdc74f Compare April 16, 2025 05:23
@tacaswell tacaswell modified the milestones: v3.11.0, v3.10.2 Apr 17, 2025
@tacaswell tacaswell merged commit c1a2ec4 into matplotlib:main Apr 17, 2025
39 of 41 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Apr 17, 2025
@QuLogic QuLogic deleted the legend-placeholders branch April 17, 2025 19:23
rcomer pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Apr 20, 2025
QuLogic pushed a commit to meeseeksmachine/matplotlib that referenced this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants