RulerPanInteraction - Ruler-pan interaction - MATLAB (original) (raw)
Main Content
Description
A ruler-pan interaction allows you to pan an axis without having to select any buttons in the axes toolbar. To enable ruler panning, set theInteractions
property of the axes to arulerPanInteraction
object. When this interaction is enabled, you can pan an axis by dragging it.
To enable multiple interactions, set the Interactions
property to an array of objects.
Creation
Syntax
Description
rp = rulerPanInteraction
creates a ruler-pan interaction object.
rp = rulerPanInteraction('Dimensions',d)
sets the Dimensions property. Use this property to constrain panning to a single axis or a subset of axes. For example,rp = rulerPanInteraction('Dimensions','x')
constrains panning to the_x_-axis.
Properties
Dimensions to allow panning, specified as one of these values:
'xyz'
— Allows panning on all three axes.'xy'
— Allows panning on the _x_- and_y_-axes only.'yz'
— Allows panning on the _y_- and_z_-axes only.'xz'
— Allows panning on the _x_- and_z_-axes only.'x'
— Allows panning on the _x_-axis only.'y'
— Allows panning on the _y_-axis only.'z'
— Allows panning on the _z_-axis only.
Examples
Create a surface plot. Get the current axes and replace the default interactions with the ruler-pan and data tip interactions. Then hover over the surface to display data tips. Drag any axis to pan the limits.
surf(peaks) ax = gca; ax.Interactions = [rulerPanInteraction dataTipInteraction];
Create x and y values, and plot them using custom _x_-axis limits. Replace the default set of interactions with a ruler-pan interaction that is restricted to the _x_-dimension. Then drag the _x_-axis to pan. Notice that you cannot pan the _y_-axis.
x = linspace(-500,500,5000); y = sin(x)./x; plot(x,y) xlim([-50 50]) ax = gca; ax.Interactions = rulerPanInteraction(Dimensions="x");
Tips
In most cases, the axes have a default set of interactions which depend on the type of chart you are displaying. You can replace the default set with a new set of interactions, but you cannot access or modify any of the interactions in the default set.
Version History
Introduced in R2019a