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.

example

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.

example

Properties

expand all

Dimensions to allow panning, specified as one of these values:

Examples

collapse all

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];

Figure contains an axes object. The axes object contains an object of type surface.

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");

Figure contains an axes object. The axes object contains an object of type line.

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