title - Add title to current axes

GUI Alternative

To create or modify a plot's title from a GUI, use Insert Title from the figure menu. Use the Property Editor, one of the plotting tools , to modify the position, font, and other properties of a legend. For details, see The Property Editor in the MATLAB Graphics documentation.

Syntax

title('string')
title(fname)
title(...,'PropertyName',PropertyValue,...)
title(axes_handle,...)
h = title(...)

Description

Each axes graphics object can have one title. The title is located at the top and in the center of the axes.

title('string') outputs the string at the top and in the center of the current axes.

title(fname) evaluates the function that returns a string and displays the string at the top and in the center of the current axes.

title(...,'PropertyName',PropertyValue,...) specifies property name and property value pairs for the text graphics object that title creates. Do not use the 'String' text property to set the title string; the content of the title should be given by the first argument.

title(axes_handle,...) adds the title to the specified axes.

h = title(...) returns the handle to the text object used as the title.

Examples

Display today's date in the current axes:

title(date)

Include a variable's value in a title:

f = 70;
c = (f-32)/1.8;
title(['Temperature is ',num2str(c),'C'])

Include a variable's value in a title and set the color of the title to yellow:

n = 3;
title(['Case number #',int2str(n)],'Color','y')

Include Greek symbols in a title:

title('\ite^{\omega\tau} = cos(\omega\tau) + isin(\omega\tau)')

Include a superscript character in a title:

title('\alpha^2')

Include a subscript character in a title:

title('X_1')

The text object String property lists the available symbols.

Create a multiline title using a multiline cell array.

title({'First line';'Second line'})

Remarks

title sets the Title property of the current axes graphics object to a new text graphics object. See the text String property for more information.

See Also

gtext, int2str, num2str, text, xlabel, ylabel, zlabel

Annotating Plots for related functions

Text Properties for information on setting parameter/value pairs in titles

Adding Titles to Graphs for more information on ways to add titles

  


 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS