Zooming in Graphs

Zooming in 2-D and 3-D

Zooming changes the magnification of a graph without changing the size of the figure or axes. Zooming is useful to see greater detail in a small area. As explained below, zooming behaves differently depending on whether it is applied to a 2-D or 3-D view.

Enable zooming by clicking one of the zoom icons . Select + to zoom in and to zoom out.

    Tip   When in zoom in mode, you can use Shift+click to zoom out (i.e., press and hold down the Shift key while clicking the mouse). You can also right-click and zoom out or restore the plot to its original view using the context menu.

Zooming in 2-D Views

In 2-D views, click the area of the axes where you want to zoom in, or drag the cursor to draw a box around the area you want to zoom in on. MATLAB® redraws the axes, changing the limits to display the specified area.

When you right-click in Zoom mode, the context menu enables you to:

  • Zoom out

  • Reset to the view of the graph when it was plotted (undo one or more changes of view)

  • Constrain zooming to expand only the x-axis (horizontal zoom)

  • Constrain zooming to expand only the y-axis (vertical zoom)

Undoing Zoom Actions

If you want to reset the graph to its original view, right-click to display the context menu and select Reset to Original View. You can also use the Undo item on the Edit menu to undo each operation you performed on your graph.

Zoom Constrained to Horizontal or Vertical

In 2-D views, you can constrain zoom to operate in either the horizontal or vertical direction. To do this, right-click to display the context menu while in zoom mode and select the desired constraint from the Zoom Options submenu, as illustrated in the previous figure. Horizontal zooming is useful for exploring time series graphs that have dense intervals. Vertical zooming can help you see minor variations in places where the YData range is small compared to the y-axis limits.

Zooming in 3-D Views

In 3-D views, moving the cursor up or to the right zooms in, while moving the cursor down or to the left zooms out. Both toolbar icons enable the same behavior. 3-D zooming does not change the axes limits, as in 2-D zooming. Instead it changes the view (specifically, the axes CameraViewAngle property) as if you were looking through a camera with a zoom lens.

Was this topic helpful?