scatterPlotMatrix: 'htmlwidget' for 'd3.js' scatter plot matrix

View source: R/scatterPlotMatrix.R

scatterPlotMatrixR Documentation

htmlwidget for d3.js scatter plot matrix

Description

htmlwidget for d3.js scatter plot matrix

Usage

scatterPlotMatrix(
  data,
  categorical = NULL,
  inputColumns = NULL,
  cutoffs = NULL,
  keptColumns = NULL,
  zAxisDim = NULL,
  distribType = 2,
  regressionType = 0,
  corrPlotType = "Circles",
  corrPlotCS = NULL,
  rotateTitle = FALSE,
  columnLabels = NULL,
  continuousCS = "Viridis",
  categoricalCS = "Category10",
  mouseMode = "tooltip",
  eventInputId = NULL,
  controlWidgets = FALSE,
  cssRules = NULL,
  plotProperties = NULL,
  slidersPosition = NULL,
  width = NULL,
  height = NULL,
  elementId = NULL
)

Arguments

data

data.frame with data to use in the chart.

categorical

List of list (one for each data column) containing the name of available categories, or NULL if column corresponds to continuous data; NULL is allowed, meaning all columns are continuous. A named list can also be provided to only indicate which columns are categorical, associating available categories to a column name.

inputColumns

List of boolean (one for each data column), TRUE for an input column, FALSE for an output column; NULL is allowed, meaning all columns are inputs. A list of column names can also be provided to only indicate which columns are inputs.

cutoffs

List of SpCutoff; a SpCutoff is a list defining a xDim, yDim and a list of xyCutoff; a xyCutoff is a pair of cutoff (one for x axis, one for y axis); a cutoff is a list containing two values (min and max values) or NULL if there is no cutoff to apply for this axis; NULL is allowed, meaning there is no cutoff to apply.

keptColumns

List of boolean (one for each data column), FALSE if column has to be ignored; NULL is allowed, meaning all columns are available. A list of column names can also be provided to only indicate which columns are to be kept.

zAxisDim

Name of the column represented by z axis (used to determine the color to attribute to a point); NULL is allowed, meaning there is no coloring to apply.

distribType

Binary code indicating the type of distribution plot (bit 1: density plot, bit 2: histogram).

regressionType

Binary code indicating the type of regression plot (bit 1: linear, bit 2: loess).

corrPlotType

String indicating the type of correlation plots to use. Supported values:

  • Circles to use a circle tree map;

  • Text to display values of correlation as colored text labels (color scale domain is ⁠[-1; 1]⁠);

  • AbsText to display values of correlation as colored text labels (color scale domain is ⁠[0; 1]⁠, absolute value of correlations is used);

  • Empty to not display values of correlation; default value is Circles.

corrPlotCS

Name of the color Scale to use for correlation plot when plot type is Text or AbsText; supported names: Viridis, Inferno, Magma, Plasma, Warm, Cool, Rainbow, CubehelixDefault, Blues,Greens, Greys, Oranges, Purples, Reds, BuGn, BuPu, GnBu, OrRd, PuBuGn, PuBu, PuRd, RdBu, RdPu, YlGnBu, YlGn, YlOrBr, YlOrRd; default value is NULL, which corresponds to RdBu if corrPlotType is Text, or Blues if corrPlotType is AbsText.

rotateTitle

TRUE if column title must be rotated.

columnLabels

List of string (one for each data column) to display in place of column name found in data, or NULL if there is no alternative name; NULL is allowed, meaning all columns are without alternative name; ⁠<br>⁠ can be used to insert line breaks.

continuousCS

Name of the color Scale to use for continuous data; supported names: Viridis, Inferno, Magma, Plasma, Warm, Cool, Rainbow, CubehelixDefault, Blues, Greens, Greys, Oranges, Purples, Reds, BuGn, BuPu, GnBu, OrRd, PuBuGn, PuBu, PuRd, RdBu, RdPu, YlGnBu, YlGn, YlOrBr, YlOrRd; default value is Viridis.

categoricalCS

Name of the color Scale to use for categorical data; supported names: Category10, Accent, Dark2, Paired, Set1; default value is Category10.

mouseMode

Type of mouse interaction. Three types are available: tooltip, filter or zoom.

eventInputId

When plot event occurred, reactive input to write to; NULL is allowed, meaning no event is sent. An event is a list with two named elements 'type' and 'value'.

  • If type is equal to zAxisChange:

    • value is the new column to use as reference (see zAxisDim argument).

  • If type is equal to cutoffChange:

    • value$adjusting is TRUE when pointer is moving, changing a cutoff;

    • value$cutoffs gives the new values for the cutoffs.

  • If type is equal to pointClicked:

    • value$pointIndex is the index of the clicked point.

controlWidgets

Tells if some widgets must be available to control plot; NULL is allowed, meaning that !HTMLWidgets.shinyMode is to use; default value is FALSE.

cssRules

CSS rules to add. Must be a named list of the form list(selector = declarations), where selector is a valid CSS selector and declarations is a string or vector of declarations.

plotProperties

Adjust some properties which can not be set through CSS (mainly size, color and opacity of points). Default value is NULL which is equivalent to:

  list(
    noCatColor = "#43665e",
    watermarkColor = "#ddd",
    point = list(
      alpha = 0.5,
      radius = 2
    ),
    regression = list(
      strokeWidth = 4
    )
  )
slidersPosition

Set initial position of sliders, specifying which columns intervals are visible. Default value is NULL which is equivalent to:

  list(
    dimCount = 8,
    xStartingDimIndex = 1,
    yStartingDimIndex = 1
  )
width

Integer in pixels defining the width of the widget.

height

Integer in pixels defining the height of the widget.

elementId

Unique CSS selector id for the widget.

Examples

 if(interactive()) {
   library(scatterPlotMatrix)

   scatterPlotMatrix(iris, zAxisDim = "Species")
   # Each point has a color depending of its 'Species' value

   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")
   # 'cyl' and four last columns have a box representation for categories
   # (use top slider to see the last three columns)

   scatterPlotMatrix(iris, zAxisDim = "Species", distribType = 1)
   # Distribution plots are of type 'density plot' (instead of histogram)

   scatterPlotMatrix(iris, zAxisDim = "Species", regressionType = 1)
   # Add linear regression plots

   columnLabels <- gsub("\\.", "<br>", colnames(iris))
   scatterPlotMatrix(iris, zAxisDim = "Species", columnLabels = columnLabels)
   # Given names are displayed in place of dataset column names;
   # <br> is used to insert line breaks

   scatterPlotMatrix(iris, cssRules = list(
       ".jitterZone" = "fill: pink",
       ".tick text" = c("fill: red", "font-size: 1.8em")
   ))
   # Background of plot is pink and text of axes ticks is red and greater

   scatterPlotMatrix(iris, plotProperties = list(
     noCatColor = "DarkCyan",
     point = list(
       alpha = 0.3,
       radius = 4
     )
   ))
   # Points of plots are different:
   # two times greater, with opacity reduced from 0.5 to 0.3, and a `DarkCyan` color

 }


scatterPlotMatrix documentation built on June 22, 2024, 10:50 a.m.