Wolfram Research

Function Repository Resource:

PairwiseScatterPlot

Source Notebook

Construct a scatter plot matrix

Contributed by: Wolfram Research

ResourceFunction["PairwiseScatterPlot"][m]

creates a matrix of scatter plots comparing the data in each column of m against other columns of m.

Details and Options

ResourceFunction["PairwiseScatterPlot"] returns a matrix of plots of the ith and jth columns of m.
ResourceFunction["PairwiseScatterPlot"] has the same options as Graphics, with the following additions and changes:
"DataLabels" None labels for the columns of m
"DataRanges" All range limits on the data
"DataSpacing" 0 space to place between subplots
"DataTicks" None tick specifications for the columns
"PlotDirection" {Right, Down} direction in which scatter plots are generated
PlotRange All range limits on the subplots
PlotStyle Automatic styles for the subplots
With the default setting of "PlotDirection", the subplot located at the ith row and jth column takes y coordinates from column i of m and x coordinates from column j of m.

Examples

Basic Examples

Plot pairs of columns from trivariate data:

In[1]:=
ResourceFunction["PairwiseScatterPlot"][
 Table[{x, Sin[x], Cos[x]}, {x, 0, 2 Pi, 0.1}], "DataTicks" -> True]
Out[1]=

Options

DataLabels

Use matrix column numbers as labels:

In[2]:=
ResourceFunction[
 "PairwiseScatterPlot"][{{5, 10}, {9, 6}, {10, 8}, {4, 1}, {6, 3}}, "DataLabels" -> Automatic]
Out[2]=

Give explicit labels:

In[3]:=
ResourceFunction[
 "PairwiseScatterPlot"][{{5, 10}, {9, 6}, {10, 8}, {4, 1}, {6, 3}}, "DataLabels" -> {"x", "y"}]
Out[3]=

DataRanges

Limit the range of data values:

In[4]:=
ResourceFunction[
 "PairwiseScatterPlot"][{{5, 10}, {9, 6}, {10, 8}, {4, 1}, {6, 3}}, "DataRanges" -> {{5, 10}, {2, 8}}, "DataTicks" -> Automatic]
Out[4]=

DataSpacing

Include nonzero spacing between plots:

In[5]:=
ResourceFunction[
 "PairwiseScatterPlot"][{{5, 10}, {9, 6}, {10, 8}, {4, 1}, {6, 3}}, "DataSpacing" -> .1]
Out[5]=

DataTicks

Use automatically generated ticks:

In[6]:=
ResourceFunction[
 "PairwiseScatterPlot"][{{5, 10}, {9, 6}, {10, 8}, {4, 1}, {6, 3}}, "DataTicks" -> Automatic]
Out[6]=

Define explicit tick positions:

In[7]:=
ResourceFunction[
 "PairwiseScatterPlot"][{{5, 10}, {9, 6}, {10, 8}, {4, 1}, {6, 3}}, "DataTicks" -> {{4, 6, 8}, {5, 10}}]
Out[7]=

PlotDirection

Plot with x indices increasing toward the right and y indices increasing upward:

In[8]:=
ResourceFunction[
 "PairwiseScatterPlot"][{{5, 10}, {9, 6}, {10, 8}, {4, 1}, {6, 3}}, "PlotDirection" -> {Right, Up}]
Out[8]=

Applications

Visualize the covariance matrix for some multivariate data:

In[9]:=
data = RandomReal[
   MultinormalDistribution[{0, 0, 0}, {{1, 1/2, -2/3}, {1/2, 3, 2}, {-2/3, 2, 4}}], 100];
In[10]:=
ResourceFunction["PairwiseScatterPlot"][data]
Out[10]=

Neat Examples

Overlap pairwise plots:

In[11]:=
ResourceFunction["PairwiseScatterPlot"][
 Table[{x, Sin[x], Cos[x]}, {x, 0, 2 Pi, 0.1}], "DataSpacing" -> {-1, -1}]
Out[11]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information