Skip to content

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