Graphics | ![]() ![]() |
Adding Axes Labels to a Graph
In MATLAB, an axes label is a text string aligned with the x-, y-, or z-axis in a graph. Axes labels can help explain the meaning of the units that each axis represents.
To add axes labels to a graph, you can use any of these mechanisms:
Using the Label Options on the Insert Menu
Note MATLAB opens up a horizontal text editing box for the Y- and Z- axes labels and automatically rotates the label into alignment with the axes when you finish entering text. |
Note After you use the Insert menu to add an axes label, plot edit mode is enabled in the figure, if it was not already enabled. |
Using the Property Editor to Add Axes labels
To add labels to a graph using the Property Editor:
The Property Editor displays the set of property panels specific to axes objects.
Using the Label Commands
You can add x-, y-, and z-axis labels using the xlabel
, ylabel
, and zlabel
commands. For example, these statements label the axes and add a title.
xlabel('t = 0 to 2\pi','FontSize',16) ylabel('sin(t)','FontSize',16) title('\it{Value of the Sine from Zero to Two Pi}','FontSize',16)
The labeling commands automatically position the text string appropriately. MATLAB interprets the characters immediately following the backslash "\" as TeX commands. These commands draw symbols such as Greek letters and arrows. See the text String
property for a list of TeX character sequences.
![]() | Editing a Legend | Adding Text Annotations to a Graph | ![]() |