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.
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:
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.
Click the legend. The "Property Editor" pane changes to provide customisation options for the legend.
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.
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.
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.
Use the controls in the "Font" area to control the font size and style of the text in the legend.
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.