Introduction to ‘scatterPlotMatrix’

library(scatterPlotMatrix)

Basic usage (dataset uses factor type)

scatterPlotMatrix(iris)
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

‘Species’ column is of factor type and has box representation for its categories.

slidersPosition argument

scatterPlotMatrix(iris, slidersPosition = list(
  dimCount = 3, # Number of columns to draw
  xStartingDimIndex = 2, # Index of first drawn column horizontally
  yStartingDimIndex = 2 # Index of first drawn column vertically
))
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.WidthPetal.LengthPetal.WidthSepal.WidthPetal.LengthPetal.WidthSepal.WidthPetal.LengthPetal.WidthSepal.WidthPetal.LengthPetal.Width22.533.5401020304024601020304000.511.522.50510152025303522.533.54246
4
22.533.5400.511.522.5
7
24600.511.522.5
8

Set initial position of sliders, specifying which columns intervals are visible. Here, visible columns starts at second column in x direction, second column in y direction, and three columns are represented.

zAxisDim argument (referenced column is categorical)

scatterPlotMatrix(iris, zAxisDim = "Species")
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Each point has a color depending of its ‘Species’ value.

categoricalCS argument

scatterPlotMatrix(iris, zAxisDim = "Species", categoricalCS = "Set1")
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Colors used for categories are not the same as previously (supported values: Category10, Accent, Dark2, Paired, Set1).

zAxisDim argument (referenced column is continuous)

scatterPlotMatrix(iris, zAxisDim = "Sepal.Length")
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Each point has a color depending of its Sepal.Length value.

continuousCS argument

scatterPlotMatrix(iris, zAxisDim = "Sepal.Length", continuousCS = "YlOrRd")
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Colors used for points are not the same as previously (supported values: Blues, RdBu, YlGnBu, YlOrRd, Reds).

corrPlotType argument

Supported values: Empty, Circles, Text, AbsText

scatterPlotMatrix(iris, corrPlotType = "Text")
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpecies−0.1180.8720.818NA−0.428−0.366NA0.963NANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Correlation plots use simple texts instead of circle tree maps as previously; Value of correlations is used to attribute the color, using a color scale with a domain [-1; 1] and the palette RdBu.

scatterPlotMatrix(iris, corrPlotType = "AbsText")
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpecies−0.1180.8720.818NA−0.428−0.366NA0.963NANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Absolute value of correlations is used to attribute the color, using a color scale with a domain [0; 1] and palette ‘Blues’.

Basic usage (dataset doesn’t use factor type)

scatterPlotMatrix(mtcars)
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
mpgcyldisphpdratwtqsecvsmpgcyldisphpdratwtqsecvsmpgcyldisphpdratwtqsecvsmpgcyldisphpdratwtqsecvs1015202530024681045678024681012141002003004005000246810020030002468101233.544.550246810234502468101416182022024681000.20.40.60.81051015101520253045678
9
1015202530100200300400500
17
45678100200300400500
18
1015202530100200300
25
45678100200300
26
100200300400500100200300
27
101520253033.544.55
33
4567833.544.55
34
10020030040050033.544.55
35
10020030033.544.55
36
10152025302345
41
456782345
42
1002003004005002345
43
1002003002345
44
33.544.552345
45
10152025301416182022
49
456781416182022
50
1002003004005001416182022
51
1002003001416182022
52
33.544.551416182022
53
23451416182022
54
101520253000.20.40.60.81
57
4567800.20.40.60.81
58
10020030040050000.20.40.60.81
59
10020030000.20.40.60.81
60
33.544.5500.20.40.60.81
61
234500.20.40.60.81
62
141618202200.20.40.60.81
63

Several columns are of numerical type but should be of factor type (for example cyl).

categorical argument

categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8)
scatterPlotMatrix(mtcars, categorical = categorical, zAxisDim = "cyl")
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
mpgcyldisphpdratwtqsecvsmpgcyldisphpdratwtqsecvsmpgcyldisphpdratwtqsecvsmpgcyldisphpdratwtqsecvsNANANANANANANANANANANANANA10152025300246810468024681012141002003004005000246810020030002468101233.544.5502468102345024681014161820220246810010510151015202530468
9
1015202530100200300400500
17
468100200300400500
18
1015202530100200300
25
468100200300
26
100200300400500100200300
27
101520253033.544.55
33
46833.544.55
34
10020030040050033.544.55
35
10020030033.544.55
36
10152025302345
41
4682345
42
1002003004005002345
43
1002003002345
44
33.544.552345
45
10152025301416182022
49
4681416182022
50
1002003004005001416182022
51
1002003001416182022
52
33.544.551416182022
53
23451416182022
54
101520253001
57
46801
58
10020030040050001
59
10020030001
60
33.544.5501
61
234501
62
141618202201
63

cyl and four last columns have a box representation for categories (use top slider to see the last three columns).

distribType argument

scatterPlotMatrix(iris, zAxisDim = "Species", distribType = 1)
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567800.10.20.30.40.522.533.5400.20.40.60.811.224600.10.20.30.400.511.522.500.20.40.60.8setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Distribution plots are of type ‘density plot’ (instead of histogram).

regressionType argument

scatterPlotMatrix(iris, zAxisDim = "Species", regressionType = 1)
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Add linear regression plots.

cutoffs argument

cutoffs <- list(
  list(
    xDim = "Sepal.Length",
    yDim = "Species",
    xyCutoffs = list(
      list(c(4, 8), c(-0.1, 0.1)),
      list(c(4, 8), c(1.9, 2.1))
    )
  )
)
scatterPlotMatrix(iris, zAxisDim = "Species", cutoffs = cutoffs)
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Traces which are not kept by cutoffs are greyed; only kept traces are used for histograms.

rotateTitle argument

scatterPlotMatrix(iris, zAxisDim = "Species", rotateTitle = TRUE)
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Column names are rotated (can be useful for long column names).

columnLabels argument

columnLabels <- gsub("\\.", "<br>", colnames(iris))
scatterPlotMatrix(iris, zAxisDim = "Species", columnLabels = columnLabels)
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
LengthSepalWidthSepalLengthPetalWidthPetalSpeciesLengthSepalWidthSepalLengthPetalWidthPetalSpeciesSepalLengthSepalWidthPetalLengthPetalWidthSpeciesLengthSepalWidthSepalLengthPetalWidthPetalSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Given names are displayed in place of column names found in dataset; <br> is used to insert line breaks.

cssRules argument

scatterPlotMatrix(iris, cssRules = list(
  ".jitterZone" = "fill: pink", # Set background of plot to pink
  ".tick text" = c("fill: red", "font-size: 1.8em") # Set text of axes ticks red and greater
))
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Apply CSS to the plot. CSS is a simple way to describe how elements on a web page should be displayed (position, colour, size, etc.). You can learn the basics at W3Schools. You can learn how to examine and edit css at MDN Web Docs for Firefox or Chrome devtools for Chrome.

plotProperties argument

scatterPlotMatrix(iris, plotProperties = list(
  noCatColor = "DarkCyan", # Color used when categories coloring is not applied
  point = list(
    alpha = 0.3, # Opacity value used for points
    radius = 4 # Radius used to draw points as circles
  )
))
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Adjust some properties which can not be set through CSS (mainly size, color and opacity of points). Here, points of plot are customised: two times greater, with opacity reduced from 0.5 to 0.3, and a DarkCyan color.

controlWidgets argument

scatterPlotMatrix(iris, controlWidgets = TRUE, width = 770, height = 770)
Distribution Representation:
Continuous Color Scale:
Categorical Color Scale:
Correlation Plot Type:
Correlation Color Scale:
Mouse mode:
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesSepal.LengthSepal.WidthPetal.LengthPetal.WidthSpeciesNANANANA4567805101520253022.533.5401020304024601020304000.511.522.505101520253035setosaversicolorvirginica010203040504567822.533.54
6
45678246
11
22.533.54246
12
4567800.511.522.5
16
22.533.5400.511.522.5
17
24600.511.522.5
18
45678setosaversicolorvirginica
21
22.533.54setosaversicolorvirginica
22
246setosaversicolorvirginica
23
00.511.522.5setosaversicolorvirginica
24

Widgets are added above the graph, allowing to modify some of its attributes.