开发者

How do I get text to rotate correctly?

I can never seem to get text to rotate correctly inside a plot, whereas the same text rotates perfectly otherwise. For example,

Plot[Sin[x], {x, -2 Pi, 2 Pi}, 
 Epilog -> 
  First@Graphics[Rotate[Text["Sine", {Pi, 1/2}], -30 Degree]]]

gives the following.

开发者_Python百科

How do I get text to rotate correctly?

The text is skewed and hardly legible. How do I rotate the text correctly?


The skewing happens because the text is directly included and the scale of the two axis is not the same. If you set AspectRatio to Automatic the scale will be the same and the text is readable:

Plot[Sin[x], {x, -2 Pi, 2 Pi}, 
 Epilog -> First@Graphics[Rotate[Text["Sine", {Pi, 1/2}], -30 Degree]],
 AspectRatio -> Automatic
]

How do I get text to rotate correctly?

To keep the aspect ratio (which is probably what you want), wrap the text in Inset:

Plot[Sin[x], {x, -2 Pi, 2 Pi},
 Epilog -> Inset[Rotate[Text["Sine"], -70 Degree], {Pi, 1/2}]
]

How do I get text to rotate correctly?


You can also move the Rotate inside the Text:

Plot[Sin[x], {x, -2 Pi, 2 Pi}, 
 Epilog -> Text[Rotate["Sine", -70 Degree], {Pi, 1/2}]]

which will also avoid the skewing from the aspect ratio.

How do I get text to rotate correctly?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜