| Contents | Index |
LegendText sets the text for the legend entry of an object.
|
Attribute |
Type |
Value |
See Also:
See Also:
Section Legends in this document.
Details:
LegendText is a technical internal attibute. You will most likely want to use the library interface attribute Legend in order to set legend entries.
LegendText sets the text for the legend entry of an object. To have a legend entry, the object must have Legend set to TRUE and LegendVisible must be TRUE for the enclosing scene. Cf. example 1.
If LegendText is unset, but Legend and LegendVisible are TRUE, the legend entry is taken from the attribute Name. If that is unset, too, the name of the object type is displayed. Cf. example 2.
Example 1
We create a few objects with values for LegendText set:
f := plot::Function2d(sin(x), x = 0..PI,
LegendText = "f(x)", Color = RGB::Red):
g := plot::Function2d(cos(x), x = 0..PI,
LegendText = "f'(x)", Color = RGB::Blue):
p := plot::Point2d([2, sin(2)], PointSize = 3*unit::mm,
LegendText = "(2; f(2))", Color = RGB::Black):
Switching on the legend, we plot these objects:
plot(f, g, p, LegendVisible = TRUE)

As we can see, only the function objects show up in the legend. If p is supposed to be shown there, too, we must explicitly set LegendEntry to TRUE:
p::LegendEntry := TRUE:
plot(f, g, p, LegendVisible = TRUE)

Example 2
If an object has a legend entry, but LegendText is not set, the first fall-back is the Name attribute of the object:
plot(plot::Function3d(sin(x^2 + y^2), x = -2..2, y = -2..2,
Color = RGB::Green, FillColorType = Flat,
LegendText = "LegendText: sin",
Name = "Name: sin"),
plot::Function3d(cos(x + y), x = -2..2, y = -2..2,
Color = RGB::Blue, FillColorType = Flat,
Name = "Name: cos"),
LegendVisible)

As a last resort, the name of the type of object is used:
plot(plot::Rectangle(0..1, 0..1),
plot::Point2d(frandom(), frandom()),
plot::Point2d(frandom(), frandom()),
plot::Point2d(frandom(), frandom()),
plot::Point2d(frandom(), frandom()),
plot::Point2d(frandom(), frandom()),
LegendEntry = TRUE, LegendVisible = TRUE)


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 |