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.
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
]
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}]
]
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.
精彩评论