Main Content

InteractionOptions Properties

Axes interaction behavior for apps

Since R2023a

InteractionOptions properties control the behavior of axes interactions for apps. By changing property values, you can customize the behavior of all associated axes interactions. Use dot notation to query and set properties.

f = uifigure;
ax = uiaxes(f);
ax.InteractionOptions.LimitsDimensions = "x";

The options set by the InteractionOptions object apply to these interactions on the associated axes:

  • The built-in interactions specified by the Interactions property of the axes

  • Interactions enabled by using mode functions such as pan and zoom

  • Interactions enabled using the axes toolbar

The properties listed here are valid for axes in App Designer and for axes in figures created with the uifigure function.

Bounding Limits

expand all

Pan and zoom dimension constraint, specified as one of the values in this table.

ValueDescription
"x"

Constrain pan and zoom interactions to the x-dimension.

"y"

Constrain pan and zoom interactions to the y-dimension.

"z"

Constrain pan and zoom interactions to the z-dimension.

"xy"

Constrain pan and zoom interactions to the x- and y-dimensions.

"yz"

Constrain pan and zoom interactions to the y- and z-dimensions.

"xz"

Constrain pan and zoom interactions to the x- and z-dimensions.

"xyz"

Constrain pan and zoom interactions to the x, y, and z-dimensions.

Example: ax.InteractionOptions.LimitsDimensions = "x"

Bounded pan indicator, specified as "on", "off", logical 1 (true), or 0 (false). The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState. If "on", the pan interaction is bounded by the minimum and maximum limit values specified in the OuterXLimits, OuterYLimits, and OuterZLimits properties.

If the axes contains an image, then the default value of PanLimitsBounded is "on". Otherwise, the default value is "off".

Example: ax.InteractionOptions.PanLimitsBounded = "on"

Bounded zoom indicator, specified as "on", "off", logical 1 (true), or 0 (false). The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState. If "off", the zoom interaction is not bounded by the minimum and maximum limit values specified in the OuterXLimits, OuterYLimits, and OuterZLimits properties.

Example: ax.InteractionOptions.ZoomLimitsBounded = "off"

Minimum and maximum pan and zoom limits, specified as a two-element vector of the form [min max], where max is greater than min. You can specify the limits as numeric, categorical, datetime, or duration values. However, the type of values that you specify must match the type of values along the corresponding axis.

You can specify both limits, or specify one limit and let MATLAB® automatically calculate the other. For an automatically calculated minimum or maximum limit, use -Inf or Inf, respectively. MATLAB uses the "tight" limit method to calculate the corresponding limit.

Example: ax.InteractionOptions.OuterXLimits = [0 10]

Example: ax.InteractionOptions.OuterYLimits = [-10 10]

Example: ax.InteractionOptions.OuterZLimits = [0 5]

Supported Interactions

expand all

Pan support indicator, specified as "on", "off", logical 1 (true), or 0 (false). The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState. If "off", the pan interaction is not included in the default interactions of the axes and the pan mode is not supported. For example, pan(ax,"on") is not supported.

Example: ax.InteractionOptions.PanSupported = "off"

Zoom support indicator, specified as "on", "off", logical 1 (true), or 0 (false). The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState. If "off", the zoom interaction is not included in the default interactions of the axes and the zoom mode is not supported. For example, zoom(ax,"on") is not supported.

Example: ax.InteractionOptions.ZoomSupported = "off"

Rotate support indicator, specified as "on", "off", logical 1 (true), or 0 (false). The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState. If "off", the rotate interaction is not included in the default interactions of the axes and the rotate mode is not supported. For example, rotate3d(ax,"on") is not supported.

Example: ax.InteractionOptions.RotateSupported = "off"

Data tip support indicator, specified as "on", "off", logical 1 (true), or 0 (false). The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState. If "off", the data tip interaction is not included in the default interactions of the axes and the data tip mode is not supported. For example, datacursormode(ax,"on") is not supported.

Example: ax.InteractionOptions.DatatipsSupported = "off"

Brush support indicator, specified as "on", "off", logical 1 (true), or 0 (false). The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState. If "off", the brush mode is not supported. For example, brush(ax,"on") is not supported.

Example: ax.InteractionOptions.BrushSupported = "off"

Restore View

expand all

Minimum and maximum limits for restoring view of the axes, specified as a two-element vector of the form [min max], where max is greater than min. The axes limits are set to [min max] when restoring the axes view using zoom(fig,"out") or the Restore View button in the axes toolbar.

You can specify the limits as numeric, categorical, datetime, or duration values. However, the type of values that you specify must match the type of values along the corresponding axis.

You can specify both limits, or specify one limit and let MATLAB automatically calculate the other. For an automatically calculated minimum or maximum limit, use -Inf or Inf, respectively. MATLAB uses the "tight" limit method to calculate the corresponding limit.

Example: ax.InteractionOptions.RestoredXLimits = [0 5]

Example: ax.InteractionOptions.RestoredYLimits = [0 10]

Example: ax.InteractionOptions.RestoredZLimits = [-10 10]

Azimuth and elevation angles for restored view of the axes, specified as a two-element vector of the form [az el], where az and el are the azimuth and elevation with respect to the axis origin. For more information about setting the camera line-of-sight, see Setting the Viewpoint with Azimuth and Elevation.

Example: ax.InteractionOptions.RestoredView = [45 25]

Version History

Introduced in R2023a