|On this page…|
Graphics objects have two properties that control these options:
Annotation — Controls whether the graphics object appears in the legend and determines if the object or its children appear in the legend.
DisplayName — Specifies the text label used by the legend for the object. However, specifying a string with the legend commands resets the value of DisplayName property.
Querying the Annotation property returns the handle of an hg.Annotation object. The hg.Annotation object has a property called LegendInformation, which contains an hg.LegendEntry object. The hg.LegendEntry object has a property called IconDisplayStyle that you can set to one of three values.
|on||Represent this object in a figure legend.|
|off||Do not include this object in a figure legend .|
|children||Display legend entries for this object's children and not the object itself (applies only to objects that have children, otherwise, the same as on).|
For example, if object_handle is the handle of a graphics object, use the following statements to set the object's IconDisplayStyle. In this case, the graphics object, object_handle, is not included in the legend because its IconDisplayStyle property is off.
hAnnotation = get(object_handle,'Annotation'); hLegendEntry = get(hAnnotation','LegendInformation'); set(hLegendEntry,'IconDisplayStyle','off')
If a legend exists and you change its IconDisplayStyle setting, you must call legend to update the display. See the legend command for the options available.