Learn R Programming

rtemis (version 0.79)

mplot3.x: mplot3: Univariate plots: index, histogram, density, QQ-line

Description

Draw plots of 1-dimensional data: index, histogram, density, and Q-Q plots.

Usage

mplot3.x(x, type = c("index", "line", "histogram", "density", "qqline"),
  group = NULL, data = NULL, xlab = NULL, ylab = NULL,
  main = NULL, main.col = NULL, main.adj = 0, main.line = 0.5,
  main.font = 2, main.family = "", xlim = NULL, ylim = NULL,
  index.ypad = 0.1, axes = TRUE, axes.swap = FALSE,
  axes.col = NULL, tick.col = NULL, cex = 1.2, col = NULL,
  alpha = 0.75, index.type = c("p", "l"), hist.breaks = "Sturges",
  hist.type = c("bars", "lines"), hist.lwd = 3, density.line = FALSE,
  density.shade = TRUE, density.legend.side = 3,
  density.legend.adj = 0.98, density.params = list(),
  qqline.col = NULL, qqline.alpha = 0.66, pch = 16,
  point.col = NULL, point.cex = 1, point.bg.col = NULL,
  point.alpha = 0.66, hline = NULL, vline = NULL, diagonal = FALSE,
  diagonal.col = NULL, grid = FALSE, grid.col = NULL,
  grid.alpha = 0.5, grid.lty = 3, grid.lwd = 1, bg = NULL,
  plot.bg = NULL, annotation = NULL, annot.col = NULL,
  group.legend = NULL, group.title = "", group.names = NULL,
  group.side = 3, group.adj = 0.02, group.at = NA, text.xy = NULL,
  text.x = NULL, text.y = NULL, text.xy.cex = 1,
  text.xy.col = "white", line.col = "#008E00", tck = 0.02,
  x.axis.padj = -1.1, xlab.line = 1.3, y.axis.padj = 0.9,
  ylab.line = 1.6, labs.col = NULL, bty = "o", box = NULL,
  box.col = NULL, box.alpha = 1, box.lty = 1, box.lwd = 2,
  lab.adj = 0.5, density.mean = ifelse(type == "density", TRUE, FALSE),
  hline.col = "black", hline.lwd = 1, hline.lty = 1,
  vline.col = "black", vline.lwd = 1, vline.lty = 1, lty = 1,
  lwd = 2, qqline.lwd = lwd, density.lwd = lwd,
  theme = getOption("rt.theme", "lightgrid"),
  palette = getOption("rt.palette", "rtCol1"), zero.lines = NULL,
  zero.col = NULL, zero.alpha = 0.66, zero.lty = 1, zero.lwd = 1.5,
  pty = "s", mar = c(2.5, 2.5, 1.5, 1), xaxs = "r", yaxs = "r",
  autolabel = letters, new = FALSE, alpha.off = FALSE,
  na.rm = TRUE, par.reset = TRUE, export.par.orig = FALSE,
  filename = NULL, pdf.width = 6, pdf.height = 6, ...)

Arguments

x

Numeric vector or list of vectors, one for each group. If data is provided, x is name of variable in data

type

String:"index", "line", "histogram", "density", "qqline" Case-insensitive and supports partial matching: e.g. mplot3.x(x, "H") gives histogram

group

Vector denoting group membership. Will be converted to factor. If data is provided, group is name of variable if data

data

Optional data frame containing x data

xlab

String: x-axis label

ylab

String: y-axis label

main

String: Plot title

main.col

Color for title. Defaults to black for theme "light" and "box", otherwise white

main.adj

Float: Plot title alignment (0 = left, .5 = center, 1 = right)

main.line

Float: mtext line argument for the title. Higher numbers move title upwards. Default = .5

main.font

Integer: 1: regular, 2: bold, 3: italic. See par("font") for more

main.family

String: Font family to use. See par("family")

xlim

Float vector, length 2: x-axis limits

ylim

Float vector, length 2: y-axis limits

index.ypad

Float: Expand ylim by this much for plot type "index" Default = .1 (Stops points being cut off)

axes

Logical: Should the axes be drawn? Defaults to TRUE

axes.col

String: Color for axes values (box color set with box.col)

cex

Float: Character expansion factor (See ?par)

index.type

String: "p" for points (Default), "l" for lines (timeseries)

hist.breaks

See histogram("breaks")

hist.type

String: "bars" or "lines"

hist.lwd

Float: Line width for type = "histogram"; hist.type = "lines"

density.line

Logical: If TRUE, draw line for type = "density". Default = FALSE

density.shade

Logical: If TRUE, draw shaded polygon for type = "density". Default = TRUE

qqline.col

Color for Q-Q line

qqline.alpha

Float: Alpha for Q-Q line

grid

Logical: Should grid be drawn?

grid.col

Grid color

grid.alpha

Alpha for grid.col

grid.lty

Grid line type (See ?par("lty"))

grid.lwd

Grid line width

bg

Background color. Defaults to white for themes "light" and "box", black otherwise.

annotation

String: Add annotation at the bottom right of the plot

group.legend

Logical: If TRUE, include legend with group names

group.title

String: Title above group names

group.names

(Optional) If multiple groups are plotted, use these names if group.title = TRUE

tck

Float: Tick length. Can be negative (See ?par("tck"))

x.axis.padj

Adjustment for the x axis tick labels position

xlab.line

Adjustment for the x axis label position (See codeline in ?mtext)

y.axis.padj

Similar to x.axis.padj for the y axis

ylab.line

Similar to xlab.line for the y axis

labs.col

Color for labels

bty

Character: "o", "l", "7", "c", "u", or "]" result in a box resembling each character. (See ?par)

box

Logical: Should a box be drawn around the plot? Defaults to TRUE for themes "box" and "darkbox"

box.col

Box color

box.alpha

Alpha for box.col

box.lty

Box line type

lab.adj

Adjust the axes labels. 0 = left adjust; 1 = right adjust; .5 = center (Default)

density.mean

Logical: If TRUE, print mean of x along plot. Default = TRUE, for type = "density"

lwd

Integer: Line width. Used for type = "line" or "density"

theme

String: "light", "dark", "lightgrid", "darkgrid", "lightbox", "darkbox" Default = "lightgrid" if no default "rt.fit" is set using options. You can set a system-wide default in your .Rprofile by including a line like options(rt.theme = 'lightgrid')

zero.lines

Logical: If TRUE, draw lines at x = 0 and y = 0

zero.col

Color for zero.lines

zero.alpha

Color alpha for zero.lines

zero.lty

Zero line line type

zero.lwd

Zero line width

pty

"s" gives a square plot, "m" gives a plot that fills graphics device size. Defaults to "s" (See ?par)

mar

Vector, length 4: Margins; see mar in ?par

new

Logical: If TRUE, add plot to existing plot. See par("new")

na.rm

Logical: Will be passed to all functions that support it. If set to FALSE, input containing NA values will result in error, depending on the type

filename

Path to file: If supplied, plot will be printed to file

...

Additional arguments to be passed to learner function

Details

You can group data either by supplying x as a list where each element contains one vector per group, or as a data frame where each column represents group, or by providing a group variable, which will be converted to factor. For bivariate plots, see mplot3.xy and mplot3.xym. For heatmaps, see mplot3.heatmap To plot histograms of multiple groups, it's best to use hist.type = "lines", which will use mhist and space apart the breaks for each group

See Also

mplot3, mplot3.xy, mplot3.xym, mplot3.heatmap