boxplotdou {boxplotdbl} | R Documentation |
Double Box Plot
Description
Extend box plot chart into two-axes (x and y) to visualize correlation.
Usage
boxplotdou(x, ...)
## Default S3 method:
boxplotdou(x, y,
boxed.whiskers=FALSE, outliers.has.whiskers=FALSE,
name.on.axis=factor.labels, factor.labels=NULL, draw.legend=NA,
condense=FALSE, condense.severity="iqr",
condense.once=FALSE,
col=NULL,
COLOR.SHEER=bxpdou.sheer.color,
shading=NA, shading.angle=NA, blackwhite=FALSE,
STAT=bxpdou.boxplot.stat,
verbose=FALSE, plot=TRUE, ...)
## S3 method for class 'data.frame'
boxplotdou(x, y,
boxed.whiskers=FALSE, outliers.has.whiskers=FALSE,
name.on.axis=factor.labels, factor.labels=NULL, draw.legend=NA,
condense=FALSE, condense.severity="iqr",
condense.once=FALSE,
col=NULL,
COLOR.SHEER=bxpdou.sheer.color,
shading=NA, shading.angle=NA, blackwhite=FALSE,
STAT=bxpdou.boxplot.stat,
verbose=FALSE, plot=TRUE, ...)
## S3 method for class 'factor'
boxplotdou(x, obs.x, f.y, obs.y,
boxed.whiskers=FALSE, outliers.has.whiskers=FALSE,
name.on.axis=factor.labels, factor.labels=NULL, draw.legend=NA,
condense=FALSE, condense.severity="iqr",
condense.once=FALSE,
col=NULL,
COLOR.SHEER=bxpdou.sheer.color,
shading=NA, shading.angle=NA, blackwhite=FALSE,
STAT=bxpdou.boxplot.stat,
verbose=FALSE, plot=TRUE, ...)
## S3 method for class 'formula'
boxplotdou(formula.x, data.x, formula.y, data.y,
boxed.whiskers=FALSE, outliers.has.whiskers=FALSE,
name.on.axis=factor.labels, factor.labels=NULL, draw.legend=NA,
condense=FALSE, condense.severity="iqr",
condense.once=FALSE,
col=NULL,
COLOR.SHEER=bxpdou.sheer.color,
shading=NA, shading.angle=NA, blackwhite=FALSE,
STAT=bxpdou.boxplot.stat,
verbose=FALSE, plot=TRUE, ...)
## S3 method for class 'list'
boxplotdou(x,
boxed.whiskers=FALSE, outliers.has.whiskers=FALSE,
name.on.axis=factor.labels, factor.labels=NULL, draw.legend=NA,
col=NULL,
COLOR.SHEER=bxpdou.sheer.color,
shading=NA, shading.angle=NA, blackwhite=FALSE,
verbose=FALSE, plot=TRUE, ...)
Arguments
x |
data frame,
contains two columns as factor and observation to x-axis
(for |
y |
data frame,
contains two columns as factor and observation to y-axis
(for |
obs.x |
numeric vector, as observation to x-axis (for |
f.y |
factor vector, as factor to y-axis (for |
obs.y |
numeric vector, as observation to y-axis (for |
formula.x |
formula, a model formula to x-axis, eg. |
data.x |
data.frame, contains variables in formula.x
(for |
formula.y |
formula, a model formula to y-axis, eg. |
data.y |
data.frame, contains variables in formula.y
(for |
boxed.whiskers |
logical, default is FALSE, TRUE to draw rectangular range rather than whisker and staple. |
outliers.has.whiskers |
logical, default is FALSE, extend whisker and staple through outliers. |
name.on.axis |
control labels on each group on axes,
default is |
factor.labels |
control labels on each group on factor, default is NULL, using factor data, TRUE to abbreviate by alphabet letters, FALSE to draw no labels, character vector to give explicit labels, single character to use identical character, NA in vector to exclude any groups. |
draw.legend |
logical, draw legend or not, default is NA, enable legend only when labels abbreviated. |
condense |
logical, default is FALSE, TRUE to unify near groups into one box. |
condense.severity |
character, default is |
condense.once |
logical, default is FALSE,
TRUE to disable recursive condenses,
used only when |
col |
character vector, colors for each group, default is NULL, automatic colors. |
COLOR.SHEER |
function, to convert color to sheer color,
default is |
shading |
numeric vector,
as shading density to draw inside of box.
default is NA, means automatic,
no shadings when both
logical value TRUE has a special meaning to enable shading with automatic densities. |
shading.angle |
numeric vector,
as shading angle to draw inside of box.
default is NA, means automatic,
no shadings when both |
blackwhite |
logical, default is FALSE,
TRUE to draw black and white chart,
equivalent to set following 3 parameters,
|
STAT |
function, default is |
plot |
if FALSE is given, it disable to plot and print a summary. default is TRUE. |
verbose |
if TRUE is given, it print verbose debugging information. default is FALSE. |
... |
plot parameters and boxplot color parameters are acceptable. |
Details
This function is designed to visualize a correlation
between 2 sets of independent observation with common
factors.
Such as, the plant height v.s. the soil pH by location.
This function depends on boxplot
function
to calculate summaries such as IQRs.
This dependency can be overridden by STAT
argument.
Value
A summary list is explicitly printed when plot=FALSE is given, and is invisibly returned when plot=TRUE.
stat |
|
name |
|
level |
character vecotr of factor names |
Each summary of x and y is identical to boxplot
statistics,
stats |
matrix, each column contains the extreme of the lower whisker, the lower hinge, the median, the upper hinge and the extreme of the upper whisker. |
n |
numerical vector, sample numbers of each factor level. |
conf |
matrix, each column contains the lower and upper extremes of the notch. |
out |
numerical vector, outliers |
group |
numerical vector of same length as |
names |
character vector, each name of factor levels. |
boxplot color parameters
- medcol
default is NULL, to use black, colors for median labels.
- whiskcol
default is NULL, to use
col
, colors for whiskers.- staplecol
default is NULL, to use
col
, colors for staples.- boxcol
default is NULL, to use black, colors for box borders.
- outcol
default is NULL, to use
col
, colors for outliers.- outbg
default is NULL, to use transparent, colors inside outliers.
- outcex
default is 2, size of outliers.
- outpch
default is 1, to use a transparent circle, symbol number of outliers, as graphic
par
pch
.
Author(s)
Shinichiro Tomizono
References
Double Box Plot: https://tomizonor.wordpress.com/2013/03/15/double-box-plot/
Double Box Plot 1.2: https://tomizonor.wordpress.com/2013/11/24/double-box-plot-1-2/
See Also
Examples
# iris data: Sepal.Length v.s. Sepal.Width by Species
stat <- boxplotdou(iris[c(5,1)], iris[c(5,2)])
boxplotdou(iris[,5], iris[,1], iris[,5], iris[,2])
boxplotdou(Sepal.Length~Species, iris, Sepal.Width~Species, iris)
boxplotdou(stat, main='redraw by saved stat')
# color and shading
boxplotdou(iris[c(5,1)], iris[c(5,2)], col=c('wheat','wheat','black'),
boxcol='springgreen')
boxplotdou(iris[c(5,1)], iris[c(5,2)], shading=c(3,5))
boxplotdou(iris[c(5,1)], iris[c(5,2)], shading=5, shading.angle=c(0,90))
boxplotdou(iris[c(5,1)], iris[c(5,2)], blackwhite=TRUE)
# customized sheer funtion
mysheer <- function(x)
adjustcolor(x, alpha.f=0.2, red.f=0.3, green.f=0.3, blue.f=0.3)
boxplotdou(iris[c(5,1)], iris[c(5,2)], COLOR.SHEER=mysheer)
# whisker
boxplotdou(iris[c(5,1)], iris[c(5,2)], boxed.whiskers=TRUE)
boxplotdou(iris[c(5,1)], iris[c(5,2)], outliers.has.whiskers=TRUE)
# condense
boxplotdou(iris[c(5,1)], iris[c(5,2)], condense=TRUE)
# labels
boxplotdou(iris[c(5,1)], iris[c(5,2)], factor.labels=FALSE)
boxplotdou(iris[c(5,1)], iris[c(5,2)], factor.labels=TRUE)
boxplotdou(iris[c(5,1)], iris[c(5,2)], factor.labels=TRUE,
draw.legend=FALSE)
boxplotdou(iris[c(5,1)], iris[c(5,2)], factor.labels=c('Se','Ve','Vi'))
boxplotdou(iris[c(5,1)], iris[c(5,2)], factor.labels='+',
name.on.axis=FALSE)
# customized summary function
mystat <- function(x) boxplot(formula=x, range=1, plot=FALSE)
boxplotdou(iris[c(5,1)], iris[c(5,2)], STAT=mystat)
# graphic parameters
boxplotdou(iris[c(5,1)], iris[c(5,2)], xlim=c(4.8, 7.0), ylim=c(2.0, 3.5))
# print summary
boxplotdou(iris[c(5,1)], iris[c(5,2)], plot=FALSE)