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.
## 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")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(GMD)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GMD/plot.mhist.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot.mhist
> ### Title: S3 method for class 'mhist'.
> ### Aliases: plot.mhist
> ### Keywords: hplot methods
>
> ### ** Examples
>
> ## 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")
>
>
>
>
>
> dev.off()
null device
1
>