Learn R Programming

FunChisq (version 2.5.4)

plot_table: Plot a Table Using Color Intensity for Counts

Description

A table is visualized as a matrix whose cells are shown with intensity of a given color proportional to the count in each cell. The count in a cell must be real: negative numbers or non-integers are acceptable. It provides a global understanding of the underlying pattern.

Usage

plot_table(table, xlab = "Column", ylab = "Row", col = "green3",
           xaxt = "n", yaxt = "n", main = NULL,
           show.value = TRUE, value.cex = 2,
           highlight=c("row.maxima", "none"),
           highlight.col=col,
           mgp=c(0.5,0,0), mar=c(2,2,3,1.5), ...)

Arguments

table

A data frame or a matrix.

xlab

The lable of the horizontal axis.

ylab

The lable of the vertical axis.

col

The color corresponding to the maximum value in the table.

xaxt

The style of the horizontal axis. See par.

yaxt

The style of the vertical axis. See par.

main

The title of the plot.

show.value

logical. Show the value of each cell in the table on the plot.

value.cex

Relative magnification factor if values are to be put in the cell.

...

Parameters acceptable to image function in the graphics package.

highlight

Specify to highlight row maxima or no highlight. When highlighted, a box is placed around each row maximum.

highlight.col

The color used to highlight a cell in the table.

mgp

The margin (in mex units) for the axis title, labels and line. See par.

mar

The margins of the four sides of the plot. See par.

Author

Joe Song

Examples

Run this code
opar <- par(mfrow=c(2,2))
plot_table(matrix(1:6, nrow=2), col="seagreen2")

plot_table(matrix(rnorm(20), nrow=5), col="orange", show.value=FALSE)

plot_table(matrix(rpois(16, 2), nrow=4), col="cornflowerblue", highlight="none")

plot_table(matrix(rbinom(15, 8, 0.5), nrow=3), col="sienna2", highlight="none")
par(opar)

Run the code above in your browser using DataLab