scatterhistogram

Scatter plot with histograms of each variable along its edges.

Category: Graphics > 2-D and 3-D Plots

Syntax

scatterhistogram(x, y)

Draws the scatter of y against x with a marginal histogram on each axis.

scatterhistogram(tbl, xvar, yvar)

Uses two variables of a table.

scatterhistogram(___, 'GroupVariable', g)

Colors the points by group.

h = scatterhistogram(___)

Also returns the chart object.

Description

It shows the joint behavior of two variables and, along the edges, the distribution of each one, which a plain scatter plot can hide when many points overlap. With groups, the marginal histograms are drawn per group.

Input arguments

x, y
Numeric vectors of the same length.
tbl, xvar, yvar
Table and the names of two numeric variables.
'GroupVariable'
Variable that splits the points into groups.

Output arguments

h
ScatterHistogramChart object.

Example

Two variables

rng(1)
x = rand(60, 1);
y = 2*x + 0.3*rand(60, 1);
scatterhistogram(x, y);

In the app, the chart is drawn below the code.

See also

scatter histogram2 plotmatrix binscatter