Skip to content

Text ignores rotational part of transformation #698

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

Closed
stefanv opened this issue Feb 9, 2012 · 8 comments
Closed

Text ignores rotational part of transformation #698

stefanv opened this issue Feb 9, 2012 · 8 comments

Comments

@stefanv
Copy link
Contributor

stefanv commented Feb 9, 2012

When specifying a transformation to plt.text, the rotational part of the transformation is ignored. I'm aware of the rotation keyword, but in my use case, I need some more fine-grained control.

Here's an example, in which a box and text receives the same transformation, but displays differently:

from matplotlib import patches, transforms
import matplotlib.pyplot as plt
import numpy as np

ax = plt.gca()

theta = np.deg2rad(30)
S = np.sin(theta)
C = np.cos(theta)
R = transforms.Affine2D(matrix=np.array([[ C, -S, 0.5],
                                         [ S,  C, 0.5],
                                         [ 0,  0, 1.]]))

rect = patches.Rectangle((0, 0), 0.5, 0.1, transform=R + ax.transData)
text = plt.text(0, 0, 'hello', size=50, transform=R + ax.transData)

ax.add_patch(rect)

plt.show()
@mdboom
Copy link
Member

mdboom commented Feb 10, 2012

Yeah -- text rotation has evolved very strangely overtime due to the history in the Gdk API. I think we definitely need to address this. It's tricky, though, because we currently use the transformation only for text placement and we wouldn't want the scale of the transform to start affecting font size.

@efiring
Copy link
Member

efiring commented Jul 21, 2013

@mdboom, quick thought: would it make sense to have the "rotation" kwarg accept one more string, "transform", which would be telling it to take the rotation angle from the transform?

@tacaswell tacaswell added this to the v1.5.x milestone Aug 18, 2014
@tacaswell
Copy link
Member

This bug is still valid.

@tacaswell tacaswell modified the milestones: v1.5.x, v1.4.x Aug 18, 2014
@WeatherGod
Copy link
Member

I would also like to ditto this, as in mplot3d, I have to manually compute
the rotation portion. I am currently working on a completely refactored
mplot3d that would utilize the transformation framework more extensively,
and having this available would make the code just a little bit easier.

On Sun, Aug 17, 2014 at 9:18 PM, Thomas A Caswell notifications@github.com
wrote:

This bug is still valid.


Reply to this email directly or view it on GitHub
#698 (comment)
.

@tacaswell tacaswell modified the milestones: v1.4.x, 1.5.0 Feb 7, 2015
@tacaswell tacaswell modified the milestones: proposed next point release, next point release Jul 17, 2015
bearstrong added a commit to bearstrong/matplotlib that referenced this issue Mar 31, 2016
bearstrong added a commit to bearstrong/matplotlib that referenced this issue Mar 31, 2016
bearstrong added a commit to bearstrong/matplotlib that referenced this issue Apr 1, 2016
bearstrong added a commit to bearstrong/matplotlib that referenced this issue Apr 1, 2016
bearstrong added a commit to bearstrong/matplotlib that referenced this issue Apr 1, 2016
bearstrong added a commit to bearstrong/matplotlib that referenced this issue Apr 1, 2016
@story645
Copy link
Member

@bearstrong are you still working on this?

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Sep 24, 2017
@immaxchen
Copy link
Contributor

My proposal is to add a Boolean argument to Text, say, something like transform_rotation_too (just kidding, for illustration only), if it is set to True, then we transform the rotation angle accordingly, otherwise, the rotation angle stays. Does it make sense?

image

immaxchen added a commit to immaxchen/matplotlib that referenced this issue Oct 26, 2019
…lib#698)

Considering the text rotation don't get transformed may by a desired behavior
(such as text for annotation to some data point). Here made it as an option to
control whether or not the text rotation get transformed.
@immaxchen
Copy link
Contributor

Have sent a PR to address this issue, not quite sure if this is the way you want to do it.

immaxchen added a commit to immaxchen/matplotlib that referenced this issue Jun 19, 2020
…lib#698)

Considering the text rotation don't get transformed may by a desired behavior
(such as text for annotation to some data point). Here made it as an option to
control whether or not the text rotation get transformed.
QuLogic added a commit that referenced this issue Aug 11, 2020
…ormed-too-gh698

Resolve 'text ignores rotational part of transformation' (#698)
@QuLogic
Copy link
Member

QuLogic commented Jun 3, 2021

The linked PR #15532 adds an option enabling this.

@QuLogic QuLogic closed this as completed Jun 3, 2021
@QuLogic QuLogic modified the milestones: needs sorting, v3.4.0 Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants