Rectangles in 2D

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.


plot::Rectangle(xmin .. xmax, ymin .. ymax, <a = amin .. amax>, options)


plot::Rectangle( `x_{min}`..`x_{max}` , `y_{min}`..`y_{max}` ) generates the 2D rectangle with the corners (xmin, ymin), (xmin, ymax), (xmax, ymin), (xmax, ymax).

plot::Rectangle creates a 2D rectangle with edges parallel to the coordinate axes.

With Filled = FALSE, the rectangle consists only of its edges. With Filled = TRUE, it is a filled area.

The lines can be set as desired with LineStyle, LineWidth, and LineColor. Cf. Example 1.

With LinesVisible = FALSE, the edges are rendered invisible.

For filled rectangles, a FillColor and a FillPattern can be selected. Cf. Example 2.


AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
AntiAliasedantialiased lines and points?FALSE
Colorthe main colorRGB::Blue
Filledfilled or transparent areas and surfacesFALSE
FillColorcolor of areas and surfacesRGB::Red
FillPatterntype of area fillingDiagonalLines
Framesthe number of frames in an animation50
Legendmakes a legend entry 
LegendTextshort explanatory text for legend 
LegendEntryadd this object to the legend?FALSE
LineColorcolor of linesRGB::Blue
LineWidthwidth of lines0.35
LineStylesolid, dashed or dotted lines?Solid
LinesVisiblevisibility of linesTRUE
LineColorDirectionthe direction of color transitions on lines[0, 1]
LineColorDirectionXx-component of the direction of color transitions on lines0
LineColorDirectionYy-component of the direction of color transitions on lines1
Namethe name of a plot object (for browser and legend) 
ParameterEndend value of the animation parameter 
ParameterNamename of the animation parameter 
ParameterBegininitial value of the animation parameter 
ParameterRangerange of the animation parameter 
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
Titleobject title 
TitleFontfont of object titles[" sans-serif ", 11]
TitlePositionposition of object titles 
TitleAlignmenthorizontal alignment of titles w.r.t. their coordinatesCenter
TitlePositionXposition of object titles, x component 
TitlePositionYposition of object titles, y component 
VisibleAfterobject visible after this time value 
VisibleBeforeobject visible until this time value 
VisibleFromToobject visible during this time range 
VisibleAfterEndobject visible after its animation time ended?TRUE
VisibleBeforeBeginobject visible before its animation time starts?TRUE
XMaxfinal value of parameter “x”1
XMininitial value of parameter “x”-1
XRangerange of parameter “x”-1 .. 1
YMaxfinal value of parameter “y”1
YMininitial value of parameter “y”-1
YRangerange of parameter “y”-1 .. 1


Example 1

We plot two rectangles:

plot(plot::Rectangle(-2..2, -2..2, Filled = TRUE,
                     FillColor = RGB::Red),
     plot::Rectangle(1..5, 1..5, Filled = FALSE,
                     LineColor = RGB::Black,
                     LineStyle = Dashed))

Example 2

We plot rectangles with different fill patterns (FillPattern):

plot(plot::Rectangle(0..1, 2..3, Filled = TRUE,
                     FillPattern = Solid,
                     FillColor = RGB::Red),
     plot::Rectangle(1..2, 2..3, Filled = TRUE,
                     FillPattern = CrossedLines,
                     FillColor = RGB::Green),
     plot::Rectangle(2..3, 2..3, Filled = TRUE,
                     FillPattern = XCrossedLines,
                     FillColor = RGB::Blue),
     plot::Rectangle(0..1, 1..2, Filled = TRUE,
                     FillPattern = HorizontalLines,
                     FillColor = RGB::Orange),
     plot::Rectangle(1..2, 1..2, Filled = TRUE,
                     FillPattern = VerticalLines,
                     FillColor = RGB::Violet),
     plot::Rectangle(0..1, 0..1, Filled = TRUE,
                     FillPattern = DiagonalLines,
                     FillColor = RGB::Brown),
     plot::Rectangle(1..2, 0..1, Filled = TRUE,
                     FillPattern = FDiagonalLines,
                     FillColor = RGB::Cyan))


xmin .. xmax

The left and right border of the rectangle: real numerical values or arithmetical expressions of the animation parameter a.

xmin .. xmax is equivalent to the attributes XRange, XMin, XMax.

ymin .. ymax

The lower and upper border of the rectangle: real numerical values or arithmetical expressions of the animation parameter a.

ymin .. ymax is equivalent to the attributes YRange, YMin, YMax.


Animation parameter, specified as a = amin..amax, where amin is the initial parameter value, and amax is the final parameter value.

See Also

MuPAD Functions

MuPAD Graphical Primitives