Opened 15 years ago

Closed 13 years ago

#1509 closed enhancement (fixed)

[with patch, positive review] Allow text rotation in plotting

Reported by: was Owned by: was
Priority: major Milestone: sage-4.2
Component: graphics Keywords:
Cc: Merged in: sage-4.2.alpha0
Authors: Matthew Trumbell Reviewers: Karl-Dieter Crisman
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

Since axes_label is broken in plot(), one must resort to adding your
own custom labels to a plot().

It would be nice in this application, and others, if one could rotate
text objects.  For example, it
would be nice to be able to make a custom y-axis label that was
parallel to the y-axis.  I guess,
in general, the ability to rotate text would be a useful feature.

For Sage, make sure to look up how Mathematica does text rotation, etc., and use that interface instead of making something up at random.

Attachments (3)

text.py.patch (2.0 KB) - added by mrtrumbe 13 years ago.
12846.2.patch (5 bytes) - added by mrtrumbe 13 years ago.
Patch was premature. Accidental revert of other changes. Will fix shortly.
12846.patch (2.9 KB) - added by mrtrumbe 13 years ago.
This is a proper hg patch. Code is docstring tested.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 13 years ago by mrtrumbe

Regarding text rotation, can we just pass through the rotation option? This option is already available on the underlying matplotlib text objects, so it seems like a layup. I've attached a patch which accomplishes just that (it is a very minor change). This seems to work quite well here.

As for how Mathematica accomplishes it, take a look at their page: http://demonstrations.wolfram.com/HowTextRotationWorksInMathematica/

I think a solution like that would be pretty easy in sage. For example, this might work: a function which takes a text graphics primative and an angle and properly applies the rotation to the underlying matplotlib text object.

Changed 13 years ago by mrtrumbe

Attachment: text.py.patch added

comment:2 in reply to:  1 ; Changed 13 years ago by wdj

Replying to mrtrumbe:

Regarding text rotation, can we just pass through the rotation option? This option is already available on the underlying matplotlib text objects, so it seems like a layup. I've attached a patch which accomplishes just that (it is a very minor change). This seems to work quite well here.

I tried to download it and got a strange method. I guess it is not an hg patch but a diff?

Also, did you include an example in the docstring to illustrate your new feature?

comment:3 in reply to:  2 ; Changed 13 years ago by mrtrumbe

Replying to wdj:

I tried to download it and got a strange method. I guess it is not an hg patch but a diff?

Also, did you include an example in the docstring to illustrate your new feature?

Sorry, I'm new to sage dev practices...is there documentation on generating a standard patch? I used diff to generate the attached patch.

I didn't include an example usage in the docstrings, but did include explanation of the feature. I'll update the docstring accordingly and update the patch.

comment:4 in reply to:  3 Changed 13 years ago by wdj

Replying to mrtrumbe:

Replying to wdj:

I tried to download it and got a strange method. I guess it is not an hg patch but a diff?

Also, did you include an example in the docstring to illustrate your new feature?

Sorry, I'm new to sage dev practices...is there documentation on generating a standard patch? I used diff to generate the attached patch.

http://www.sagemath.org/doc/developer/conventions.html and http://www.sagemath.org/doc/developer/producing_patches.html

I didn't include an example usage in the docstrings, but did include explanation of the feature. I'll update the docstring accordingly and update the patch.

Thanks.

Changed 13 years ago by mrtrumbe

Attachment: 12846.2.patch added

Patch was premature. Accidental revert of other changes. Will fix shortly.

comment:5 Changed 13 years ago by mrtrumbe

Ugh. Can't seem to delete patch files. Sorry for the clutter.

Changed 13 years ago by mrtrumbe

Attachment: 12846.patch added

This is a proper hg patch. Code is docstring tested.

comment:6 Changed 13 years ago by kcrisman

Authors: Matthew Trumbell
Reviewers: Karl-Dieter Crisman
Summary: plotting -- improve text support[with patch, positive review] Allow text rotation in plotting

This is really neat, as the graphic says! It makes good sense to get more of the mpl functionality exposed, even if axes_labels now works again. Positive review. Apply only most recent patch.

comment:7 Changed 13 years ago by mhansen

Merged in: sage-4.2.alpha0
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.