Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Rotated text labels

222 views
Skip to first unread message

koringkriek

unread,
Jan 13, 2010, 5:59:31 AM1/13/10
to
Hi,
I want to add text labels on my plots and some of them need to be
rotated. Usually I do it this way, eg.

Show[
Plot[Sin[x],{x,0,10}],
Graphics[Rotate[Text[Style[" Text ",Medium,FontFamily->"Helvetica" ],
{1,0.5}],Pi/4]]
]

But as you can see, the label is distorted. This is not the case if
the aspect ratio of the plot is set to automatic:

Show[
Plot[Sin[x],{x,0,10}, AspectRatio->Automatic],
Graphics[Rotate[Text[Style[" Text ",Medium,FontFamily->"Helvetica" ],
{1,0.5}],Pi/4]]
]

But it is very rare that I can (want to) set the AspectRatio option to
Automatic in my plots.

Is there any way to get the rotated text labels that are not
distorted?

Cheers
Anna

David Park

unread,
Jan 14, 2010, 5:47:35 AM1/14/10
to
Do the rotation in the Text statement.

Plot[Sin[x], {x, 0, 10},
Epilog -> {Text[
Style[" Text ", 14, FontFamily -> "Helvetica"], {1, 0.5}, {0,
0}, {1, 3}]}]


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/

dh

unread,
Jan 14, 2010, 5:50:03 AM1/14/10
to

Hi,

if you rotate the text it is interpreted as graphics and displayed

correspondingly. Therefore, use the direction argument of "Text":

Plot[Sin[x], {x, 0, 10},

Epilog ->

Text[Style[" Text ", Medium, FontFamily -> "Helvetica"], {1,

0.5}, {0, 0}, {1, 2}]]

Daniel

Albert Retey

unread,
Jan 14, 2010, 5:50:25 AM1/14/10
to

I think the recommended way to do something like this would be using Inset:

Show[
Plot[Sin[x], {x, 0, 10}],

Graphics[Inset[


Style[" Text ", Medium, FontFamily -> "Helvetica"],

{1, 0.5}, {0, 0}, 1, {1/2, 1/Sqrt[2]}
]]
]

or

Plot[Sin[x], {x, 0, 10},

Epilog -> Inset[


Style[" Text ", Medium, FontFamily -> "Helvetica"],

{1, 0.5}, {0, 0}, 1, {1/2, 1/Sqrt[2]}
]
]

you might want to look up the various arguments of inset an their
meanings in the documentation...

hth,

albert

Patrick Scheibe

unread,
Jan 14, 2010, 5:50:48 AM1/14/10
to
Hi,

just rotate the Style-Object first

Show[{
Plot[Sin[x], {x, 0, 10}],

Graphics[Text[
Rotate[Style[" Text ", Medium, FontFamily -> "Helvetica"], -Pi/
3], {2.5, Sin[2.5]}]]
}, AspectRatio -> 0.2]

Cheers
Patrick


On Wed, 2010-01-13 at 05:59 -0500, koringkriek wrote:
> Hi,
> I want to add text labels on my plots and some of them need to be
> rotated. Usually I do it this way, eg.
>
> Show[
> Plot[Sin[x],{x,0,10}],
> Graphics[Rotate[Text[Style[" Text ",Medium,FontFamily->"Helvetica" ],
> {1,0.5}],Pi/4]]
> ]
>
> But as you can see, the label is distorted. This is not the case if
> the aspect ratio of the plot is set to automatic:
>
> Show[
> Plot[Sin[x],{x,0,10}, AspectRatio->Automatic],
> Graphics[Rotate[Text[Style[" Text ",Medium,FontFamily->"Helvetica" ],
> {1,0.5}],Pi/4]]
> ]
>
> But it is very rare that I can (want to) set the AspectRatio option to
> Automatic in my plots.
>
> Is there any way to get the rotated text labels that are not
> distorted?
>

> Cheers
> Anna
>


0 new messages