quadPlot | R Documentation |
This function creates a "quad-plot" used for interpreting data that represents four aspects of each subject (e.g., the probability that an individual belongs to one of four populations). The plot is typically a square with each corner assigned a different color. The closer an object in the main plot is to one of four "assignments" (e.g., populations), the more the corresponding color is shown, with assignments of intermediate value displaying as a mixture of colors. Labels for the four corners can be added.
quadPlot(
x,
cols = c("white", "cyan", "black", "red"),
main = "",
labels = colnames(x),
labelCex = 0.6,
labelAdj = 1,
background = TRUE,
n = 25,
style = "pies",
pch = 21,
radius = 0.01,
border = "black",
na.rm = FALSE,
...
)
x |
Data frame or matrix with 4 columns, each representing the relative probabilities of belonging to one of 4 aspects. Each row will be represented by a point on the plot. |
cols |
Character list. Names of four colors to be used to create a gradient to fill the color swatch. The first color will be assigned to the lower left corner, the second to the upper left, third to upper right, and fourth to lower right. Note that not every color combination produces a map with a unique color at each coordinate of the color swatch. |
labels |
Character vector used to name the four corners of the color swatch in this order: bottom left, top left, top right, bottom right. Leave as |
labelCex |
Numeric, size of label text. |
labelAdj |
Numeric, usually between 0 and 1. Position of corner labels relative to the corners of the swatch. |
background |
Logical, if |
n |
Positive integer, number of squares used to approximate a smooth color map for the background. This is the number of cells along each side of the swatch. Higher values create less "blocky" plots but increase drawing time. |
style |
Character, either |
pch |
Used when |
na.rm |
Logical, if |
... |
Arguments to pass to |
Note that there is not a unique (1-to-1) mapping of the 4 values to position on the plot. For example, if belonging solely to population A is represented by placing a point in the lower left corner, population B in the upper left, C the upper right, and D the lower right, then belonging strongly to population A and weakly to C will place a point near the location close to the location where a point belonging strongly to A and weakly to B and D will also lie.
Nothing (side effect is to create a plot).
colorFrom4Vector
, legendQuad
data(religion)
head(religion)
religion$others <- rowSums(religion[ , c('unaffiliated', 'hindu', 'folk', 'other', 'jewish')])
religs <- c('christian', 'muslim', 'buddhist', 'others')
par(mfrow=c(1, 2))
quadPlot(religion[ , religs], main='Religion by Country', radius=0.04)
quadPlot(religion[ , religs], 'points', background=FALSE, main='Religion by Country', cex=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.