Skip to Main Content Skip to Search
Product Documentation

plot::Text3d3D text

plot::Text3d(text, [x, y, z]) draws the text string text at the position [x, y, z].

→ Examples

Call:

plot::Text3d(text, [x, y, z], <a = amin .. amax>, Options)

Parameters:

text

the text: a string. Alternatively, a procedure that accepts one input parameter a (the animation parameter) and returns a string. 
text is equivalent to the attribute Text.

x, y, z

the position of the text. The coordinates x, y, z must be real numerical values or arithmetical expressions of the animation parameter a
x, y, z are equivalent to the attributes Position, PositionX, PositionY, PositionZ.

See Also:

plot, plot::copy, plot::Text2d, stringlib::formatf

Details:

Example 1

We draw the text string `Hello world' at the anchor point (1, 2, 3) which is indicated by a red dot:

plot(plot::Circle3d(3, [1, 2, 3], [0, 0, 1]),
     plot::Point3d([1, 2, 3]),
     plot::Text3d("Hello world!", [1, 2, 3],
                  HorizontalAlignment = Center),
     Axes = Frame, TextFont = [24],
     PointColor = RGB::Red, PointSize = 3*unit::mm)

MuPAD graphics

Example 2

We animate the anchor points of the following texts and demonstrate various alignment possibilities:

plot(plot::Circle3d(1, [0, 0, 0], [0, 0, 1]),
     plot::Point3d([sin(a), cos(a), 0], a = 0..2*PI),
     plot::Point3d([cos(a), -sin(a), 0], a = 0..2*PI),
     plot::Point3d([-sin(a), -cos(a), 0], a = 0..2*PI),
     plot::Point3d([-cos(a), sin(a), 0], a = 0..2*PI),
     PointColor = RGB::Red, PointSize = 3*unit::mm,
     plot::Text3d("Hello (1)", [sin(a), cos(a), 0], a = 0..2*PI),
     plot::Text3d("Hello (2)", [cos(a), -sin(a), 0], a = 0..2*PI,
                  HorizontalAlignment = Left,
                  VerticalAlignment = BaseLine),
     plot::Text3d("Hello (3)", [-sin(a), -cos(a), 0], a = 0..2*PI,
                  HorizontalAlignment = Center,
                  VerticalAlignment = Top),
     plot::Text3d("Hello (4)", [-cos(a), sin(a), 0], a = 0..2*PI,
                  HorizontalAlignment = Right,
                  VerticalAlignment = Bottom),
     TextFont = [Italic, 24], Axes = Frame,
     CameraDirection = [0, -1, 10])

MuPAD graphicsimage

Example 3

In contrast to plot::Text2d, a 3D text may not consist of several lines. The newline character \n in MuPAD strings does not have any effect:

plot(plot::Text3d("A 3D text cannot \nhave several\nlines",
                  HorizontalAlignment = Center,
                  [0, 0, 0]),
     Axes = Frame, TextFont = [20])

MuPAD graphics

Example 4

Per default, the attribute Billboarding = TRUE is set. The text always faces the observer:

plot(plot::Circle3d(1, [0, 0, 0], [0, 0, 1]),
     plot::Point3d([-cos(a), -sin(a), 0], a = 0 .. 2*PI),
     plot::Point3d([cos(a), sin(a), 0], a = 0 .. 2*PI),
     plot::Text3d("Hello (1)", [-cos(a), -sin(a), 0],
                  a = 0 .. 2*PI),
     plot::Text3d("Hello (2)", [cos(a), sin(a), 0],
                  a = 0 .. 2*PI),
     Axes = Frame, TextFont = [20],
     PointColor = RGB::Red, PointSize = 2*unit::mm)

MuPAD graphicsimage

We use TextOrientation to fix the orientation of the texts in space. The first text lies in a plane parallel to the x-y plane, the second text is parallel to the x-z plane. Note that we have to specify Billboarding = FALSE for TextOrientation to have an effect:

plot(plot::Circle3d(1, [0, 0, 0], [0, 0, 1]),
     plot::Point3d([-cos(a), -sin(a), 0], a = 0 .. 2*PI),
     plot::Point3d([cos(a), sin(a), 0], a = 0 .. 2*PI),
     PointColor = RGB::Red, PointSize = 2*unit::mm,
     plot::Text3d("Hello (1)", [-cos(a), -sin(a), 0],
                  a = 0 .. 2*PI,
                  TextOrientation = [1, 0, 0, 0, 1, 0]),
     plot::Text3d("Hello (2)", [cos(a), sin(a), 0],
                  a = 0 .. 2*PI,
                  TextOrientation = [1, 0, 0, 0, 0, 1]),
     Billboarding = FALSE, TextFont = [20], Axes = Frame)

MuPAD graphicsimage

Example 5

The text of a text object can be animated if the text string is provided by a procedure. We use stringlib::formatf to format the animation parameter that is passed to the procedure as a floating point number for each frame of the animation:

plot(plot::Text3d(a -> stringlib::formatf(a, 2, 5)." sec",
                  [0, 0, 0], a = 0..20),
     TextFont = [60],
     HorizontalAlignment = Center, VerticalAlignment = Center,
     Axes = Frame, Frames = 201, TimeRange = 0..20)

MuPAD graphicsimage

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS