This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Rotation of a 2D text

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Value Summary

OptionalReal-valued expression (interpreted in radians)

Graphics Primitives

ObjectsTextRotation Default Values
plot::Integral, plot::Text2d0


TextRotation sets the rotation angle of a 2D text object relative to the horizontal axis.

TextRotation rotates a text object of type plot::Text2d. around its anchor point (the attribute Position of a plot::Text2d object). Note that a plot::Text2d allows different alignments (HorizontalAlignment, VerticalAlignment) relative to this point.

The rotation angle in TextRotation = angle has to be entered in radians. If positive, the rotation is counterclockwise.

The rotation of the text refers to 'rotation on the screen'. It is invariant w.r.t. rescaling of the canvas, aspect ratio etc.

While TextRotation is used for rotating 2D texts, TextOrientation is used for rotating a 3D text of type plot::Text3d.

TextRotation can be animated.


Example 1

We draw a rectangle and a rotating text inside:

r := plot::Rectangle(0..4, 0..4):
p := plot::Point2d([2, 2], PointSize = 3*unit::mm):
text := plot::Text2d("Hello world!", [2, 2], 
                     HorizontalAlignment = Center,
                     TextRotation = a, a = 0..2*PI,
                     TextFont = [24]):
plot(r, p, text):

We change the alignment of the text w.r.t. its anchor point [2, 2]:

text:: HorizontalAlignment := Left:
text:: VerticalAlignment := Top:
plot(r, p, text):

text:: HorizontalAlignment := Center:
text:: VerticalAlignment := Center:
plot(r, p, text):

delete r, p, text:

See Also

MuPAD Functions

Was this topic helpful?