Skip to Main Content Skip to Search
Product Documentation

title - Add title to current axes

Alternatives

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'])

Make a multi-colored title:

title(['\fontsize{16}black {\color{magenta}magenta '...
'\color[rgb]{0 .5 .5}teal \color{red}red} black again']) 

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'})

To change the default interpreter from Tex, set the Interpreter property as:

title('X_1','Interpreter', 'none');

This displays the string X_1 in the title of the figure instead of making 1subscript of X. See Interpreter for other options for the property and also Text Properties for other text properties.

Tips

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 | Text Properties | xlabel | ylabel | zlabel

How To

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS