Skip to content

test annotate(textcoords=offset fontsize) - #25989

Merged
rcomer merged 1 commit into
matplotlib:mainfrom
saranti:offset_fontsize
May 28, 2023
Merged

rcomer merged 1 commit into
matplotlib:mainfrom
saranti:offset_fontsize

Conversation

@saranti

@saranti saranti commented May 27, 2023

Copy link
Copy Markdown
Contributor

PR summary

PR checklist

Closes #25907. Adds a test to check that the annotation offset_fontsize parameter actually offsets the text by the correct fontsize units. The unit distance was measured by comparing the fontsize against the number of points in offset_points

Comment thread lib/matplotlib/tests/test_text.py Outdated
if i == 0:
points_coords = str(ann.get_window_extent())
else:
fontsize_coords = str(ann.get_window_extent())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would spell the whole thing

anns = [ax.annotate(...) for i in ...]
point_coords, fontsize_coords = [ann.get_window_extent() for ann in anns]
assert str(point_coords) == str(fontsize_coords)

but either way works.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If you're happy with that, I'll squash it down 👍

@saranti
saranti force-pushed the offset_fontsize branch from 8bd1824 to ecbc1c9 Compare May 28, 2023 13:45
@rcomer rcomer added this to the v3.8.0 milestone May 28, 2023
@rcomer
rcomer merged commit 3218d1f into matplotlib:main May 28, 2023
@saranti
saranti deleted the offset_fontsize branch January 24, 2024 08:35
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.

[ENH]: Add test for annotate(textcoods="offset fontsize")

3 participants