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"Nonelabels for the columns of m
"DataRanges"Allrange limits on the data
"DataSpacing"0space to place between subplots
"DataTicks"Nonetick specifications for the columns
"PlotDirection"{Right, Down}direction in which scatter plots are generated
PlotRangeAllrange limits on the subplots
PlotStyleAutomaticstyles 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 (1) 

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 (7) 

DataLabels (2) 

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 (1) 

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 (1) 

Include nonzero spacing between plots:

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

DataTicks (2) 

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 (1) 

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 (1) 

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 (1) 

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

Version History

  • 1.0.0 – 28 March 2019

License Information