Documentation Center |
On this page… |
---|
Properties Controlling Axes Size Using OuterPosition as the ActivePositionProperty ActivePositionProperty = OuterPosition |
When you create a graph, MATLAB^{®} automatically creates an axes to display the graph. The axes is sized to fit in the figure and automatically resizes as you resize the figure. However, MATLAB applies the automatic resize behavior only when the axes Units property is set to normalized (the default).
Note: MATLAB changes only the current axes' properties by default. If your plot has multiple axes, MATLAB will not automatically resize any secondary axes. |
You can control the resize behavior of the axes using the following axes properties:
OuterPosition — The boundary of the axes including the axis labels, title, and a margin. For figures with only one axes, this is 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 automatically 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.
The following graph shows the areas defined by the OuterPosition, Position expanded by TightInset , and Position properties.
When you add axis labels and a title, the TightInset changes to accommodate the additional text, as shown in the following graph.
Now 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 the text is not cut off. Compare the next two graphs, which have both been resized to the same figure size.
The following picture shows how these properties apply to 3-D graphs.
Using the OuterPosition property as the ActivePositionProperty is an effective way to prevent titles and labels from being overwritten when there are multiple axes in a figure.
The following picture illustrates how MATLAB resizes the axes to accommodate the multiline titles on the lower two axes.
The default 3-D view is azimuth = -37.5°, elevation = 30°.