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.
The annotations of a MuPAD® plot may include a legend. A legend is a small table that relates the color of an object with some text explaining the object:
f := 3*x*sin(2*x): g := 4*x^2*cos(x): h := sin(4*x)/x: plotfunc2d(f, g, h, x = 0..PI/2):
By default, legends are provided only by
plotfunc3d. These routines define the
legend texts as the expressions with which the functions are passed
A corresponding plot command using primitives of the
does not generate the legend automatically:
plot(plot::Function2d(f, x = 0..PI/2, Color = RGB::Red), plot::Function2d(g, x = 0..PI/2, Color = RGB::Green), plot::Function2d(h, x = 0..PI/2, Color = RGB::Blue)):
However, legends can be requested explicitly:
plot(plot::Function2d(f, x = 0..PI/2, Color = RGB::Red, Legend = "Function 1: ".expr2text(f)), plot::Function2d(g, x = 0..PI/2, Color = RGB::Green, Legend = "Function 2: ".expr2text(g)), plot::Function2d(h, x = 0..PI/2, Color = RGB::Blue, Legend = "Function 3: ".expr2text(h)) ):
Each graphical primitive accepts the attribute
Passing this attribute to an object triggers several actions:
LegendEntry are visible
in the “object inspector” of the interactive viewer
(see section Viewer,
Browser, and Inspector: Interactive Manipulation) and can be
manipulated interactively for each single primitive after selection
in the “object browser.” The attribute
associated with the scene object accessible via the “object
At most 20 entries can be displayed in a legend. If more entries are specified in a plot command, the surplus entries are ignored. Further, the legend may not cover more than 50% of the height of the drawing area of a scene. Only those legend entries fitting into this space are displayed; remaining entries are ignored.
If the attribute
LegendText = TRUE is set
for a primitive, its legend entry is determined as follows:
If the attribute
LegendText is specified,
its value is used for the legend text.
Here are all attributes relevant for legends:
Attributes for Legend
|attribute name||possible values/example||meaning||default||browser entry|
|add this object to the legend?||primitive|
|see section Fonts||font for the legend text||sans-serif 8|