This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Add Text to Graph Interactively

This example shows how to interactively add a title, legend, axis labels, and other text to a graph using the figure menus and plot tools.

Add Title and Axis Labels

Create a simple line plot.

x = linspace(1,10);
Use the figure Insert menu to add a title and axis labels to the graph. After typing the text, click anywhere outside the text entry box to apply the text.

To modify the title and axis labels, first enable plot edit mode by clicking the Edit Plot button on the figure toolbar.

  • To change the text, double-click it and type new text.

  • To move the text, drag it to a new position.

  • To set text properties, such as the color and font style, right-click the text and use the context menu.

  • To set additional properties, use the Property Editor. Select Show Property Editor from the context menu.

Add Legend

Add a legend to the graph. In the figure, select Insert > Legend.

By default, the legend labels each plotted object with data1, data2, and so on. Change the legend label by double-clicking the label and retyping a new label. Display special characters and symbols using TeX markup. For example, use the _ character to display a subscript. For a list of supported TeX markup, see the text Interpreter property.


To display a legend with more than 50 items, use the legend function.

To change the legend location, right-click the legend and set the Location option from the context menu. For additional location options, or to modify other legend properties, use the Property Editor. Select View > Property Editor to open the Property Editor. Then, click the legend to access its properties.

Add Annotations to Graph

Add a text box and a text arrow to the graph using the TextBox and Text Arrow options from the Insert menu. To add a text box, draw a rectangle and then type the text at the text cursor. To add a text arrow, draw an arrow from tail to head and type the text at the text cursor next to the tail.

See Also

| | | |

Related Topics

Was this topic helpful?