This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

regionZoomInteraction

Region-zoom interaction

Description

A region-zoom interaction allows you to zoom into a rectangular region of a 2-D chart without having to select any buttons in the axes toolbar. To enable region zooming, set the Interactions property of the axes to a regionZoomInteraction object. When this interaction is enabled, you can zoom into a region by dragging within the chart.

To enable multiple interactions, set the Interactions property to an array of objects.

Creation

Syntax

rz = regionZoomInteraction
rz = regionZoomInteraction('Dimensions',d)

Description

example

rz = regionZoomInteraction creates a region-zoom interaction object.

example

rz = regionZoomInteraction('Dimensions',d) sets the Dimensions property. Use this property to constrain zooming to specific dimensions. For example, rz = regionZoomInteraction('Dimensions','x') constrains zooming to the x-dimension.

Properties

expand all

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

  • 'xyz' — Allows zooming in all dimensions.

  • 'xy' — Allows zooming in the x and y dimensions only.

  • 'yz' — Allows zooming in the y and z dimensions only.

  • 'xz' — Allows zooming in the x and z dimensions only.

  • 'x' — Allows zooming in the x dimension only.

  • 'y' — Allows zooming in the y dimension only.

  • 'z' — Allows zooming in the z dimension only.

Examples

collapse all

Create a plot of fifty random numbers. Get the current axes, and replace the default interactions with the region-zoom and data tip interactions. Then hover over the plotted points to display data tips. Drag to zoom into a region of the plot.

plot(rand(1,50),'-o')
ax = gca;
ax.Interactions = [regionZoomInteraction dataTipInteraction];

Create a scatter plot of normally distributed random data. Replace the default set of interactions with a region-zoom interaction that operates only in the x-dimension. Then drag within the plot to zoom into a region of interest.

x = linspace(-1,1,1000);
y = randn(1,1000);
scatter(x,y,'.')
ax = gca;
ax.Interactions = regionZoomInteraction('Dimensions','x');

Limitations

Region-zoom interactions are not supported in 3-D axes or in the Live Editor.

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.

Introduced in R2019a