HorizontalAlignment, TitleAlignment, VerticalAlignment

Horizontal alignment of text objects w.r.t. their coordinates

MuPAD® notebooks will be removed in a future release. 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

HorizontalAlignment, TitleAlignmentInheritedCenter, Left, or Right
VerticalAlignmentInheritedBaseLine, Bottom, Center, or Top

Graphics Primitives

ObjectsDefault Values
plot::Text2d, plot::Text3d

HorizontalAlignment: Left

TitleAlignment: Center

VerticalAlignment: BaseLine


HorizontalAlignment: Left

TitleAlignment: Center

VerticalAlignment: Bottom


TitleAlignment controls the interpretation of the TitlePosition of the titles of graphical objects.

HorizontalAlignment and VerticalAlignment control the interpretation of the coordinates of text objects.

Titles of graphical objects are placed at the position defined by TitlePosition. TitleAlignment determines whether the beginning, the center, or the end of the title text is aligned at this position. See Example 1.

Text objects (i.e., objects of type plot::Text2d or plot::Text3d) carry, in their Position attribute, a position. HorizontalAlignment and VerticalAlignment together determine which point of the text this position refers to. For example, with HorizontalAlignment = Left and HorizontalAlignment = Bottom, the given position is the lower left corner of the rendered text.


Example 1

We plot three points with title positions 0.1 above each point. The titles are aligned such that the beginning of the text (Left), the center of the text (Center), or the end of the text (Right) is at the TitlePosition:

plot(plot::Point2d(0, 0, Title = "Point 1", 
                   TitlePosition = [0, 0.1],
                   TitleAlignment = Left),
     plot::Point2d(1, 1, Title = "Point 2", 
                   TitlePosition = [1, 1.1],
                   TitleAlignment = Center),
     plot::Point2d(2, 2, Title = "Point 2", 
                   TitlePosition = [2, 2.1],
                   TitleAlignment = Right),
     PointSize = 2.5*unit::mm)

Example 2

The following call generates a table showing all the combinations of HorizontalAlignment and VerticalAlignment:

Hor := [Left, Center, Right]:
Vert := [Top, BaseLine, Center, Bottom]:
plot((plot::Text2d(expr2text(Hor[i], Vert[j]), [i, j],
                   HorizontalAlignment = Hor[i],
                   VerticalAlignment   = Vert[j]),
      plot::Point2d([i, j], Color = RGB::Black))
     $ i = 1..3 $ j = 1..4, Axes = None,
     TitleFont = [13], PointSize = 2.5*unit::mm)

delete Hor, Vert:

See Also

MuPAD Functions