xlabel, ylabel, zlabel - Label x-, y-, and z-axis

GUI Alternative

To control the presence and appearance of axis labels on a graph, use the Property Editor, one of the plotting tools . For details, see The Property Editor in the MATLAB Graphics documentation.

Syntax

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


ylabel(...)
ylabel(axes_handle,...)
h = ylabel(...) 


zlabel(...)
zlabel(axes_handle,...)
h = zlabel(...)

Description

Each axes graphics object can have one label for the x-, y-, and z-axis. The label appears beneath its respective axis in a two-dimensional plot and to the side or beneath the axis in a three-dimensional plot.

xlabel('string') labels the x-axis of the current axes.

xlabel(fname) evaluates the function fname, which must return a string, then displays the string beside the x-axis.

xlabel(...,'PropertyName',PropertyValue,...) specifies property name and property value pairs for the text graphics object created by xlabel.

xlabel(axes_handle,...), ylabel(axes_handle,...), and zlabel(axes_handle,...) plot into the axes with handle axes_handle instead of the current axes (gca).

h = xlabel(...), h = ylabel(...), and h = zlabel(...) return the handle to the text object used as the label.

ylabel(...) and zlabel(...) label the y-axis and z-axis, respectively, of the current axes.

Remarks

Reissuing an xlabel, ylabel, or zlabel command causes the new label to replace the old label.

For three-dimensional graphics, MATLAB puts the label in the front or side, so that it is never hidden by the plot.

Examples

Create a multiline label for the x-axis using a multiline cell array:

xlabel({'first line';'second line'})

Create a bold label for the y-axis that contains a single quote:

ylabel('George''s Popularity','fontsize',12,'fontweight','b')

See Also

strings, text, title

Annotating Plots for related functions

Adding Axis Labels to Graphs for more information about labeling axes

  


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