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 the
Interactions property of the axes to a
rulerPanInteraction 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.
rp = rulerPanInteraction
rp = rulerPanInteraction('Dimensions',d)
rp = rulerPanInteraction creates a ruler-pan interaction
Dimensions to allow panning, specified as one of these values:
'xyz' — Allows panning on all three axes.
'xy' — Allows panning on the x- and
'yz' — Allows panning on the y- and
'xz' — Allows panning on the x- and
'x' — Allows panning on the x-axis
'y' — Allows panning on the y-axis
'z' — Allows panning on the z-axis
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');
rulerPanInteraction function is not supported in the Live
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.