How to edit a legend in matlab

Written by michael carroll
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to edit a legend in matlab
Customise your plot's legend with MATLAB's Plotting Tools. (Thinkstock/Comstock/Getty Images)

MATLAB's plotting features allow you to produce rich graphical representations of your data suitable for presentation and analysis. Use MATLAB's Plotting Tools to create and edit plots of your data with a graphical user interface. A legend can be added to a plot using the "Insert Legend" button in the Plotting Tools or with the "legend" function in code. Edit a plot's legend using the Plotting Tools interface.

Skill level:
Moderately Easy

Other People Are Reading

Instructions

  1. 1

    Open a figure that has a legend or create a new one to work on by typing the following set of commands into the Command Window:

    ezplot('sin(x)')

    hold on

    ezplot('cos(x)')

    legend('sin','cos')

  2. 2

    Click the "Show Plot Tools and Dock Figure" button in the figure's window or type "plottools" into the Command Window. Maximize the figure's window so you can access the tools easily. There should be three panes around the plot, one beneath it and the other two to the sides. Make sure at least the "Property Editor" pane is visible by clicking the "View" menu and clicking "Property Editor" to enable it if necessary.

  3. 3

    Click the legend. The "Property Editor" pane changes to provide customisation options for the legend.

  4. 4

    Click any of the small rectangles in the "Location" display to move the legend to the spot indicated. You can also click and drag the legend itself to move it. Enable the "best" radio button to let MATLAB decide where to place the legend.

  5. 5

    Choose "Horizontal" or "Vertical" from the "Orientation" drop-down menu to change how the items in the legend are listed. If the "best" radio button is selected, the legend may be moved to accommodate its new dimensions. Resize the legend arbitrarily by dragging the boxes on its corners and sides.

  6. 6

    Change the border colour and background colour of the legend using the two "Colors" drop-down menus. The left one determines the border colour, and the right the background colour.

  7. 7

    Use the controls in the "Font" area to control the font size and style of the text in the legend.

  8. 8

    Edit the contents of the legend using the "Plot Browser" pane (enable it in the "View" menu if necessary). Click a legend item in the list in this pane, then change its properties in the "Property Editor" pane. Use the "Display Name" field to change the text title that shows in the legend. Change the colour of the item with the relevant control in the area beneath the "Plot Type" drop-down menu.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.