|On this page…|
Axes properties control the layout of titles and axis labels within the figure. You can control which dimensions axes can change to accommodate the titles and labels by setting the appropriate properties.
When you create a graph, MATLAB® creates an axes to display the graph. The axes is sized to fit in the figure and automatically resizes as you resize the figure. MATLAB applies the automatic resize behavior only when the axes Units property is set to normalized (the default).
You can control the resize behavior of the axes using the following axes properties:
OuterPosition — Defines the boundary of the axes including the axis labels, title, and a margin. For figures with only one axes, OuterPosition encompasses the interior of the figure.
Position — The boundary of the axes, excluding the tick marks and labels, title, and axis labels.
ActivePositionProperty — Specifies whether to use the OuterPosition or the Position property as the size to preserve when resizing the figure containing the axes.
TightInset — The margins MATLAB adds to the width and height of the Position property to include text labels, title, and axis labels. This property is read only.
Units — Keep this property set to 'normalized' to enable automatic axes resizing.
Note: MATLAB changes only the current axes' properties by default. If your plot has multiple axes, MATLAB does not automatically resize any secondary axes.
The following graph shows the areas defined by the OuterPosition, the Position expanded by TightInset , and the Position properties.
When you add axis labels and a title, the TightInset changes to accommodate the additional text.
The size of the rectangle defined by the TightInset and Position properties includes all graph text. The Position and OuterPosition properties remain unchanged.
As you resize the figure, MATLAB maintains the area defined by the TightInset and Position so that the text is not cut off. Compare the next two graphs, which have both been resized to the same figure size.
The following figure shows how the default property values apply to 3-D graphs.
When there are multiple axes in a figure use the ActivePositionProperty to prevent titles and labels from being overwritten .
The following figure illustrates how MATLAB resizes the axes to accommodate the multiline titles on the lower two axes when the ActivePositionProperty is 'position'.
Setting the ActivePositionProperty property to 'outerposition' reduces the height of the two upper axes to provide better spacing of the subplots.