plot.mhist: S3 method for class 'mhist'.

Description Usage Arguments Details References See Also Examples

View source: R/ghist.R

Description

S3 method for class mhist

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## S3 method for class 'mhist'
plot(x, beside = TRUE, labels = NULL, colors = NULL,
  main = NULL, sub = NULL, ylab = NULL, xlab = NULL, xticks = NULL,
  xlabels = NULL, vlinePos = NULL, x.las = 1, xticks.type = c("pretty",
  "original"), xlim = NULL, ylim = NULL, type = NULL, font.type = 1,
  font.family = c("sans", "serif", "mono"), cex.main = 1.75,
  cex.sub = cex.main * 0.9, cex.lab = 1.25, cex.tickmark = 0.75,
  cex.legend = 1.5, tcl = -0.25, omi = c(0.5, 0.5, 1, 0.25), mar = c(4,
  1, 0, 1), mgp = c(0, 0.5, 0), bin.unit = 0.8, legend.lab = labels,
  legend.pos = c("topright", "top", "topleft"), ...)

Arguments

x

a numeric matrix or data frame, representing distributions by rows (bins by columns); or a list of numeric vectors as distributions.

beside

logical, whether plot histograms side-by-side.

labels

a string vector of labels for the histograms in x; should have the same number as of the histograms.

colors

the colors for the histograms; by default they are set to colors generated from palette Dark2. Colors will be recycled if the size is smaller than the number of the histograms.

main

an overall title for the plot. See help("title", package="graphics").

sub

a subtitle for the plot, describing the distance and/or alignment gap (the "shift").

ylab

a title for the y axis. See help("title", package="graphics").

xlab

a title for the x axis. See help("title", package="graphics").

xticks

a string vector indicating the tickmark labels at x-axis. Defult: NULL.

xlabels

character, labels at x-axis.

vlinePos

numeric, posiitons for vertical lines.

x.las

numeric in 0,1,2,3; the style of axis labels. See option las inhelp("par", package="graphics").

xticks.type

stinrg in "pretty","original", whether plot the xticks in a pretty way or as is.

xlim

range of x values, as in help("plot", package="graphics").

ylim

range of y values, as in help("plot", package="graphics").

type

type of plot, as in help("plot", package="graphics").

font.type

the name of a font type for drawing text. See font in par. DEFAULT: font.type = 1, corresponding to plain text.

font.family

the name of a font family for drawing text. See family in par; DEFAULT: font.family = "sans", corresponding to san serif typeface.

cex.main

a numerical value giving the amount by which main-title should be magnified relative to the default.

cex.sub

a numerical value giving the amount by which sub-title should be magnified relative to the default.

cex.lab

a numerical value giving the amount by which xlab and ylab should be magnified relative to the default.

cex.tickmark

a numerical value giving the amount by which tickmarks should be magnified relative to the default.

cex.legend

a numerical value giving the amount by which legends should be magnified relative to the default.

tcl

the length of tick marks as a fraction of the height of a line of text. See option tcl inhelp("par", package="graphics").

omi

a vector of the form 'c(bottom, left, top, right)' giving the size of the outer margins in inches. See option omi inhelp("par", package="graphics").

mar

a numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot. See option mar inhelp("par", package="graphics").

mgp

the margin line (in 'mex' units) for the axis title, axis labels and axis line. See option mgp inhelp("par", package="graphics").

bin.unit

numeric, indicating the width of a group of bar(s) in unit of x axis.

legend.lab

legend labels, a string vector of the same length of distributions in x, using labels by default. No legend is displayed when it is NA.

legend.pos

string, a keyword to be used to position the legend. See help("legend", package="graphics").

...

arguments to be passed to method plot.mhist, such as graphical parameters (see par).

Details

Given a list, matrix or data.frame of histograms, plot multiple histograms side-by-side or as subplots.

References

See help(GMD)

See Also

mhist mhist.summary plot.mhist.summary plot.gmdp plot.gmdm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## load library
require("GMD")

## create two normally-distributed samples
## with unequal means and unequal variances
set.seed(2012)
v1 <- rnorm(1000,mean=-5, sd=10)
v2 <- rnorm(1000,mean=10, sd=5)

## create common bins
n <- 20 # desired number of bins
breaks <- gbreaks(c(v1,v2),n) # bin boundaries
x <-
  list(ghist(v1,breaks=breaks,digits=0),
       ghist(v2,breaks=breaks,digits=0))
mhist.obj <- as.mhist(x)

## plot histograms side-by-side
plot(mhist.obj,mar=c(1.5,1,1,0),
main="Histograms of simulated normal distributions")

## plot histograms as subplots,
## with corresponding bins aligned
plot(mhist.obj,beside=FALSE,mar=c(1.5,1,1,0),
     main="Histograms of simulated normal distributions")

GMD documentation built on May 29, 2017, 10:41 a.m.