8000 Fix vertical alignment of text by stefraynaud · Pull Request #13029 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix vertical alignment of text #13029

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
Dec 23, 2018
Merged

Fix vertical alignment of text #13029

merged 2 commits into from
Dec 23, 2018

Conversation

stefraynaud
Copy link
Contributor

PR Summary

This solves #13028: when rotation_mode='anchor' and "verticalaligment="center_baseline", the vertical alignment is wrong even if rotation=0. The vertical position of text was badly computed in this configuration, and the PR solves the problem.

PR Checklist

@jklymak
Copy link
Member
jklymak commented Dec 21, 2018

This should get a test I think. Was center_baseline working at all with rotation_mode='anchor'?

@stefraynaud
Copy link
Contributor Author
stefraynaud commented Dec 21, 2018

@jklymak You are right. I added a test that makes sure settting rotation_mode doesn't change anything if rotation=0.

@QuLogic
Copy link
Member
QuLogic commented Dec 23, 2018

Do you know if rotation != 0 appears reasonable?

@timhoffm
Copy link
Member

rotation != 0 seems to be reasonable:

plt.plot([0, 1], lw=0)
plt.axvline(.5, linewidth=.5, color='.5')
plt.axhline(.5, linewidth=.5, color='.5')

N = 4
for r in range(N):
    plt.text(.5, .5, 'pP', color=plt.get_cmap('jet')(r/N), size=100, rotation=r/N*360, va='center_baseline', rotation_mode='anchor')

before:
image

after:
image

The rotation center is not at (0.5, 0.5) but at the edge of the "p". However, I'm unsure if that's supposed to happen, also it's the same before and after this PR. So if that's an issue it's a separate one.

@timhoffm timhoffm merged commit edeccc6 into matplotlib:master Dec 23, 2018
@timhoffm
Copy link
Member

Thanks, and congratulations on your first contribution to Matplotlib! Hoping to see you back some time.

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.

5 participants
0