Graphics    

Editing the Legend

A legend is implemented as a separate axes object containing one or more line objects, representing samples of the plots in the graph, and one or more text objects, representing the labels for each data set plotted in a graph.

You can edit a legend when plot editing mode is enabled or when it is not enabled.

Editing a Legend in Plot Editing Mode

When you enable plot editing mode, you can edit any of the objects that make up a legend as you would any other axes, line, or text object in a graph. For example, if you double-click on the legend axes, the Property Editor displays the set of property panels for axes objects. Change the value of an axes property and click Apply.

If you double-click on a text label in a legend, MATLAB opens a text editing box around all the text labels in the legend. You can edit any of the text labels in the legend. To access the properties of these text objects, right-click on a text label and select Properties from the context-sensitive pop-up menu.

Editing a Legend When Plot Editing Mode Is Not Enabled

When plot editing mode is not enabled, you can still edit the text labels in a legend:

  1. Double-click on a text label in the legend.
  1. MATLAB opens a text edit box around the text label you selected. All the other text labels are temporarily hidden. You can only edit one text label at a time.

  1. Make changes to the text label and then click anywhere in the figure outside of the text edit box when you are finished.

MATLAB automatically resizes the legend box to fit long or multiline labels.

Resizing a Legend

To resize a legend:

  1. Start plot editing mode by selecting Edit Plot from the figure Tools menu
  2. Right-click on its axes and select Unlock Axes Position from the pop-up menu.
  3. Move the cursor back to the legend axes, which is selected, and grab one of the selection handles. MATLAB changes the cursor to indicate possible directions.

  1. Drag the selection handle to resize the legend.

Removing the Legend

If you have enabled plot editing mode, you can remove a legend by clicking on it and choosing the Cut option on the Edit menu. You can also remove a legend by right-clicking on it and selecting Cut from the context-sensitive pop-up menu.

If plot editing mode is not enabled, you can remove a legend by selecting the Legend option on the Insert menu. The Legend options acts as a toggle switch -- selecting it alternately adds or removes a legend.


  Positioning the Legend Adding Axis Labels to Graphs