biplot2d: Draw a two-dimensional biplot.

View source: R/repgrid-plots.r

biplot2dR Documentation

Draw a two-dimensional biplot.

Description

The biplot is the central way to create a joint plot of elements and constructs. Depending on the parameters chosen it contains information on the distances between elements and constructs. Also the relative values the elements have on a construct can be read off by projection the element onto the construct vector. A lot of parameters can be changed rendering different types of biplots (ESA, Slater's) and different looks (colors, text size). See the example section below to get started.

Usage

biplot2d(
  x,
  dim = c(1, 2),
  map.dim = 3,
  center = 1,
  normalize = 0,
  g = 0,
  h = 1 - g,
  col.active = NA,
  col.passive = NA,
  e.point.col = "black",
  e.point.cex = 0.9,
  e.label.col = "black",
  e.label.cex = 0.7,
  e.color.map = c(0.4, 1),
  c.point.col = "black",
  c.point.cex = 0,
  c.label.col = "black",
  c.label.cex = 0.7,
  c.color.map = c(0.4, 1),
  c.points.devangle = 91,
  c.labels.devangle = 91,
  c.points.show = TRUE,
  c.labels.show = TRUE,
  e.points.show = TRUE,
  e.labels.show = TRUE,
  inner.positioning = TRUE,
  outer.positioning = TRUE,
  c.labels.inside = FALSE,
  c.lines = TRUE,
  col.c.lines = grey(0.9),
  flipaxes = c(FALSE, FALSE),
  strokes.x = 0.1,
  strokes.y = 0.1,
  offsetting = TRUE,
  offset.labels = 0,
  offset.e = 1,
  axis.ext = 0.1,
  mai = c(0.2, 1.5, 0.2, 1.5),
  rect.margins = c(0.01, 0.01),
  srt = 45,
  cex.pos = 0.7,
  xpd = TRUE,
  unity = FALSE,
  unity3d = FALSE,
  scale.e = 0.9,
  zoom = 1,
  var.show = TRUE,
  var.cex = 0.7,
  var.col = grey(0.1),
  ...
)

Arguments

x

repgrid object.

dim

Dimensions (i.e. principal components) to be used for biplot (default is c(1,2)).

map.dim

Third dimension (depth) used to map aesthetic attributes to (default is 3).

center

Numeric. The type of centering to be performed. 0= no centering, 1= row mean centering (construct), 2= column mean centering (elements), 3= double-centering (construct and element means), 4= midpoint centering of rows (constructs). The default is 1 (row centering).

normalize

A numeric value indicating along what direction (rows, columns) to normalize by standard deviations. 0 = none, 1= rows, 2 = columns (default is 0).

g

Power of the singular value matrix assigned to the left singular vectors, i.e. the constructs.

h

Power of the singular value matrix assigned to the right singular vectors, i.e. the elements.

col.active

Columns (elements) that are no supplementary points, i.e. they are used in the SVD to find principal components. default is to use all elements.

col.passive

Columns (elements) that are supplementary points, i.e. they are NOT used in the SVD but projected into the component space afterwards. They do not determine the solution. Default is NA, i.e. no elements are set supplementary.

e.point.col

Color of the element symbols. The default is "black". Two values can be entered that will create a color ramp. The values of map.dim are mapped onto the ramp. If only one color color value is supplied (e.g. "black") no mapping occurs and all elements will have the same color irrespective of their value on the map.dim dimension.

e.point.cex

Size of the element symbols. The default is .9. Two values can be entered that will create a size ramp. The values of map.dim are mapped onto the ramp. If only one color size value is supplied (e.g. .8) no mapping occurs and all elements will have the same size irrespective of their value on the map.dim dimension.

e.label.col

Color of the element label. The default is "black". Two values can be entered that will create a color ramp. The values of map.dim are mapped onto the ramp. If only one color color value is supplied (e.g. "black") no mapping occurs and all labels will have the same color irrespective of their value on the map.dim dimension.

e.label.cex

Size of the element labels. The default is .7. Two values can be entered that will create a size ramp. The values of map.dim are mapped onto the ramp. If only one color size value is supplied (e.g. .7) no mapping occurs and all labels will have the same size irrespective of their value on the map.dim dimension.

e.color.map

Value range to determine what range of the color ramp defined in e.color will be used for mapping the colors. Default is c(.4, ,1). Usually not important for the user.

c.point.col

Color of the construct symbols. The default is "black". Two values can be entered that will create a color ramp. The values of map.dim are mapped onto the ramp. If only one color color value is supplied (e.g. "black") no mapping occurs and all construct will have the same color irrespective of their value on the map.dim dimension.

c.point.cex

Size of the construct symbols. The default is .8. Two values can be entered that will create a size ramp. The values of map.dim are mapped onto the ramp. If only one color size value is supplied (e.g. .8) no mapping occurs and all construct will have the same size irrespective of their value on the map.dim dimension.

c.label.col

Color of the construct label. The default is "black". Two values can be entered that will create a color ramp. The values of map.dim are mapped onto the ramp. If only one color color value is supplied (e.g. "black") no mapping occurs and all labels will have the same color irrespective of their value on the map.dim dimension.

c.label.cex

Size of the construct labels. The default is .7. Two values can be entered that will create a size ramp. The values of map.dim are mapped onto the ramp. If only one color size value is supplied (e.g. .7) no mapping occurs and all labels will have the same size irrespective of their value on the map.dim dimension.

c.color.map

Value range to determine what range of the color ramp defined in c.color will be used for mapping. Default is c(.4, ,1). Usually not important for the user.

c.points.devangle

The deviation angle from the x-y plane in degrees. These can only be calculated if a third dimension map.dim is specified. Only the constructs that do not depart more than the specified degrees from the x-y plane will be printed. This facilitates the visual interpretation, as only vectors represented near the current plane are shown. Set the value to 91 (default) to show all vectors.

c.labels.devangle

The deviation angle from the x-y plane in degrees. These can only be calculated if a third dimension map.dim is specified. Only the labels of constructs that do not depart more than the specified degrees from the x-y plane will be printed. Set the value to 91 (default) to show all construct labels.

c.points.show

Whether the constructs are printed (default is TRUE). FALSE will suppress the printing of the constructs. To only print certain constructs a numeric vector can be provided (e.g. c(1:10)).

c.labels.show

Whether the construct labels are printed (default is TRUE). FALSE will suppress the printing of the labels. To only print certain construct labels a numeric vector can be provided (e.g. c(1:10)).

e.points.show

Whether the elements are printed (default is TRUE). FALSE will suppress the printing of the elements. To only print certain elements a numeric vector can be provided (e.g. c(1:10)).

e.labels.show

Whether the element labels are printed (default is TRUE). FALSE will suppress the printing of the labels. To only print certain element labels a numeric vector can be provided (e.g. c(1:10)).

inner.positioning

Logical. Whether to calculate positions to minimize overplotting of elements and construct labels (default isTRUE). Note that the positioning may slow down the plotting.

outer.positioning

Logical. Whether to calculate positions to minimize overplotting of of construct labels on the outer borders (default isTRUE). Note that the positioning may slow down the plotting.

c.labels.inside

Logical. Whether to print construct labels next to the points. Can be useful during inspection of the plot (default FALSE).

c.lines

Logical. Whether construct lines from the center of the biplot to the surrounding box are drawn (default is FALSE).

col.c.lines

The color of the construct lines from the center to the borders of the plot (default is gray(.9)).

flipaxes

Logical vector of length two. Whether x and y axes are reversed (default is c(F,F)).

strokes.x

Length of outer strokes in x direction in NDC.

strokes.y

Length of outer strokes in y direction in NDC.

offsetting

Do offsetting? (TODO)

offset.labels

Offsetting parameter for labels (TODO).

offset.e

offsetting parameter for elements (TODO).

axis.ext

Axis extension factor (default is .1). A bigger value will zoom out the plot.

mai

Margins available for plotting the labels in inch (default is c(.2, 1.5, .2, 1.5)).

rect.margins

Vector of length two (default is c(.07, .07)). Two values specifying the additional horizontal and vertical margin around each label.

srt

Angle to rotate construct label text. Only used in case offsetting=FALSE.

cex.pos

Cex parameter used during positioning of labels if prompted. Does usually not have to be changed by user.

xpd

Logical (default is TRUE). Whether to extend text labels over figure region. Usually not needed by the user.

unity

Scale elements and constructs coordinates to unit scale in 2D (maximum of 1) so they are printed more neatly (default TRUE).

unity3d

Scale elements and constructs coordinates to unit scale in 3D (maximum of 1) so they are printed more neatly (default TRUE).

scale.e

Scaling factor for element vectors. Will cause element points to move a bit more to the center. (but only if unity or unity3d is TRUE). This argument is for visual appeal only.

zoom

Scaling factor for all vectors. Can be used to zoom the plot in and out (default 1).

var.show

Show explained sum-of-squares in biplot? (default TRUE).

var.cex

The cex value for the percentages shown in the plot.

var.col

The color value of the percentages shown in the plot.

...

parameters passed on to come.

Details

For the construction of a biplot the grid matrix is first centered and normalized according to the prompted options.
Next, the matrix is decomposed by singular value decomposition (SVD) into

X = UDV^T

The biplot is made up of two matrices

X = GH^T

These matrices are construed on the basis of the SVD results.

\hat{X} = UD^gD^hV^T

Note that the grid matrix values are only recovered and the projection property is only given if g + h = 1

See Also

Unsophisticated biplot: biplotSimple;
2D biplots: biplot2d, biplotEsa2d, biplotSlater2d;
Pseudo 3D biplots: biplotPseudo3d, biplotEsaPseudo3d, biplotSlaterPseudo3d;
Interactive 3D biplots: biplot3d, biplotEsa3d, biplotSlater3d;
Function to set view in 3D: home.

Examples

## Not run: 

   biplot2d(boeker)                # biplot of boeker data
   biplot2d(boeker, c.lines=T)     # add construct lines
   biplot2d(boeker, center=2)      # with column centering
   biplot2d(boeker, center=4)      # midpoint centering
   biplot2d(boeker, normalize=1)   # normalization of constructs

   biplot2d(boeker, dim=2:3)       # plot 2nd and 3rd dimension
   biplot2d(boeker, dim=c(1,4))    # plot 1st and 4th dimension

   biplot2d(boeker, g=1, h=1)            # assign singular values to con. & elem.
   biplot2d(boeker, g=1, h=1, center=1)  # row centering (Slater)
   biplot2d(boeker, g=1, h=1, center=4)  # midpoint centering (ESA)

   biplot2d(boeker, e.color="red", c.color="blue")   # change colors
   biplot2d(boeker, c.color=c("white", "darkred"))   # mapped onto color range
   
   biplot2d(boeker, unity=T)                 # scale con. & elem. to equal length
   biplot2d(boeker, unity=T, scale.e=.5)     # scaling factor for element vectors

   biplot2d(boeker, e.labels.show=F)         # do not show element labels
   biplot2d(boeker, e.labels.show=c(1,2,4))  # show labels for elements 1, 2 and 4
   biplot2d(boeker, e.points.show=c(1,2,4))  # only show elements 1, 2 and 4
   biplot2d(boeker, c.labels.show=c(1:4))    # show constructs labels 1 to 4   
   biplot2d(boeker, c.labels.show=c(1:4))    # show constructs labels except 1 to 4

   biplot2d(boeker, e.cex.map=1)   # change size of texts for elements 
   biplot2d(boeker, c.cex.map=1)   # change size of texts for constructs 

   biplot2d(boeker, g=1, h=1, c.labels.inside=T)  # constructs inside the plot
   biplot2d(boeker, g=1, h=1, c.labels.inside=T,  # different margins and elem. color 
            mai=c(0,0,0,0), e.color="red") 
 
   biplot2d(boeker, strokes.x=.3, strokes.y=.05)  # change length of strokes

   biplot2d(boeker, flipaxes=c(T, F))      # flip x axis
   biplot2d(boeker, flipaxes=c(T, T))      # flip x and y axis

   biplot2d(boeker, outer.positioning=F)   # no positioning of con.-labels

   biplot2d(boeker, c.labels.devangle=20)  # only con. within 20 degree angle

## End(Not run) 


OpenRepGrid documentation built on May 31, 2023, 5:33 p.m.