tableplot: tableplot

View source: R/plot2.R

tableplotR Documentation

tableplot

Description

Add a table to a base plot.

Usage

tableplot(
  x,
  y = NULL,
  table,
  title = NULL,
  rownames = NULL,
  colnames = NULL,
  bg = "transparent",
  cex = par("cex"),
  cex.title = cex,
  xjust = 0,
  yjust = 1,
  xpad = 0.25,
  ypad = 0.75,
  col.table = 1L,
  col.title = col.table,
  col.colnames = col.table,
  col.rownames = col.table,
  font.table = 1L,
  font.title = font.table,
  font.colnames = font.table,
  font.rownames = font.table,
  show.colnames = TRUE,
  show.rownames = FALSE,
  hlines = FALSE,
  vlines = FALSE,
  frame.colnames = FALSE,
  frame.title = FALSE,
  frame.table = FALSE,
  frame.rownames = FALSE,
  frame.type = c("box", "box", "line", "box"),
  ...
)

Arguments

x, y

the x- and y-coordinates to be used or a keyword; see xy.coords

table

a data frame or matrix

title

optional title for the table

rownames, colnames

optional labels for rows and columns (default are rownames(table) and colnames(table), respectively)

bg

background color for each table cell, recycled as needed

cex, cex.title

text size for table, title

xjust, yjust

table position relative to x and y

xpad, ypad

padding around text in cells as a proportion of the max width and height of the strings in each column

col.table, col.title, col.colnames, col.rownames

colors for table, title, column names, and row names

font.table, font.title, font.colnames, font.rownames

fonts for table, title, column names, and row names

show.colnames, show.rownames

logical; if TRUE, column and row names of table are added

hlines, vlines

logical; if TRUE, horizontal and/or vertical lines are drawn between table cells

frame.colnames, frame.title, frame.table, frame.rownames

logical; if TRUE, draws a frame around the object

frame.type

a vector giving the type of framing for column names, title, table, and row names, respectively; options are "box" or "line"; alternatively, a character string with the first letter for each, e.g., "blbl"

...

additional graphical parameters passed to par

Value

A list with components table, colnames, title, and outline giving the coordinates of the rectangle for each.

See Also

addtable2plot

Examples

tbl <- head(mtcars, 3)
plot(mpg ~ wt, mtcars)

tableplot(
  'topright', table = tbl,
  title = 'mtcars data set', cex.title = 2
)

tableplot(
  par('usr')[1], 35, tbl[, 1:3],
  show.rownames = TRUE, col.rownames = 1:3,
  font.colnames = 2, hlines = TRUE
)

tableplot(
  'bottomleft', table = tbl[, 1:3], col.table = 1:3,
  show.rownames = TRUE, frame.rownames = TRUE, frame.type = 'bbll'
)


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.