Main Content

Interactively Explore and Analyze Plotted Data

These examples show how to interactively explore data by using interactions built into the axes, such as zooming, panning, and adding data tips. These examples also show how to interactively analyze data by brushing data, visualizing statistics, and adding annotations.

Explore Data

You can create a plot for variables in your workspace by selecting one or more variables in the Workspace panel and choosing a plot type from the gallery on the Plots tab.

For example, create two variables in the workspace.

x = linspace(0,10);
y = exp(.1*x) .* sin(3*x);
y(1:15) = 0;

Create a line plot for variables x and y. Select the variables in the Workspace panel by holding Shift and clicking them. Then, select the line plot in the gallery on the Plots tab.

Workspace panel with selected variables x and y, with the Plots tab showing a gallery of plot types for these variables

MATLAB® creates a line plot for the selected variables.

Line plot

Zoom and Pan Data

The axes have several interactions for exploring your data that are enabled by default. For 2-D Cartesian plots, you can zoom in and out by scrolling or pinching the axes or pan across the data by dragging the axes. To return to the original view, pause on the axes and click the Restore view button on the axes toolbar that appears.

For example, zoom into a region of the plotted data.

Zoomed-in view of the line plot

Display Data Values Using Data Tips

Data tips allow you to view the values of the data points you select. You can create persistent data tips by clicking data points or temporary data tips by pausing on a data point.

For example, display the values of three data points in persistent data tips.

Line plot with three pinned data tips that display the X and Y values for each data point

Analyze Data

Brush and Modify Data Values

Data brushing is an interaction that is not enabled on the axes by default. You can enable brushing by pausing on the axes and clicking the Brush data button on the axes toolbar that appears. Brush a data point by clicking it, or draw a rectangular region around multiple data points. Then, right-click the selection and select an option from the context menu to replace, remove, export, or copy the data points.

For example, brush a region of data points in the plot and use the context menu to remove them.

Line plot containing brushed data points highlighted in red. A context menu shows the Remove Brushed option.

Visualize Descriptive Statistics

You can compute and visualize descriptive statistics directly on your plot. Click Data Statistics on the Tools tab of the figure, and choose the statistics to add. You can also save these statistics to the workspace.

For example, add lines to your plot that represent the minimum, maximum, and mean y-values.

The Data Statistics window shows the selected min, max, and mean statistics for the variable Y, and the plot displays dashed horizontal lines representing those statistics.

Annotate Plot

You can add annotations to draw attention to aspects of your plot. Select an annotation from the gallery on the Figure tab.

For example, create a text arrow annotation.

Plot with a text arrow annotation, with the cursor in the text box for the annotation text

Display Multiple Figures in Tiled View

To arrange two figures side-by-side, undock the figures in the same window and select Tile All on the Layout tab of the figure window. To access additional layout options, such as arranging tiles and alphabetizing tabs, click the Document actions button at the top right of the figure.

Figure window with Figure 1 on the left and Figure 2 on the right

See Also

Functions

Tools

Topics