patternboxplot: Plot a boxplot using patterns and colors to fill the boxes.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/patternboxplot.R

Description

The patternboxplot function is a tool for creating versatile boxplots by filling the boxplots with colors and patterns.

Usage

 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
26
27
28
29
30
31
32
patternboxplot(
  data,
  x,
  y,
  group = NULL,
  xlab = "",
  ylab = "",
  label.size = 3.5,
  linetype = rep("solid", ifelse(is.null(group), length(unique(x)),
    length(unique(group)))),
  outlier.shape = 21,
  outlier.color = "black",
  outlier.size = 1,
  pattern.type,
  pattern.color = rep("black", ifelse(is.null(group), length(unique(x)),
    length(unique(group)))),
  pattern.line.size = rep(5, ifelse(is.null(group), length(x), length(unique(group)))),
  background.color = rep("white", ifelse(is.null(group), length(unique(x)),
    length(unique(group)))),
  frame.color = rep("black", ifelse(is.null(group), length(unique(x)),
    length(unique(group)))),
  frame.size = 1,
  pixel = 20,
  density = rep(7, ifelse(is.null(group), length(unique(x)), length(unique(group)))),
  legend.type = "h",
  legend.h = 6,
  legend.x.pos = 1.1,
  legend.y.pos = 0.49,
  legend.w = 0.2,
  legend.pixel = 20,
  legend.label
)

Arguments

data

the data to be used.

x

the variable used on x axis.

y

the variable used on y axis.

group

the variable used as the second grouping variable on x axis.

xlab

a character string to give x axis label.

ylab

a character string to give y axis label.

label.size

the font size of legend labels shown above the boxplots.

linetype

the linetype for the borders of boxplots.

outlier.shape

the shape of outlier dots.

outlier.color

the color of outlier dots.

outlier.size

the size of outlier dots.

pattern.type

a vector of patterns to be filled in the boxes The pattern types include: 'blank', 'bricks', 'vdashes', 'hdashes', 'crosshatch','dots', 'grid','hlines','nelines', 'nwlines', 'vlines', 'waves' and more.

pattern.color

a vector of colors for the lines/dots of patterns.

pattern.line.size

a vector of numeric values, the line size for the lines/dots of patterns.

background.color

a vector of colors to be filled in the boxes.

frame.color

the color for the borders of boxes.

frame.size

a numeric value, the line size for the borders of boxes.

pixel

a numeric value, the pixel resolution of boxplot.

density

a numeric vector, the density for the lines/dots of patterns.

legend.type

if legend.type='h', the layout of legends is horizontal; if legend.type='v', the layout of legends is vertical.

legend.h

a numeric value to change the height of legend boxes.

legend.x.pos

a numeric value to change the position of legends on x axis.

legend.y.pos

a numeric value to change the position of legends on y axis.

legend.w

a numeric value to change the width of legends.

legend.pixel

a numeric value to change pixel of legends.

legend.label

a vector to name legend labels.

Details

patternboxplot function offers flexible ways of doing boxplots.

Value

A ggplot object.

Author(s)

Chunqiao Luo (chunqiaoluo@gmail.com)

See Also

Function imageboxplot

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
26
27
28
library(patternplot)
library(png)
library(ggplot2)

#Example 1
data <- read.csv(system.file("extdata", "fruits.csv", package="patternplot"))
group<-data$Fruit
y<-data$Weight
x<-data$Store

pattern.type<-c('nwlines', 'blank', 'waves')
pattern.color=c('black','black', 'black')
background.color=c('white','gray80', 'white')
frame.color=c('black', 'black', 'black')
pattern.line.size<-c(6, 1,6)
density<-c(6, 1, 8)
patternboxplot(data,x, y,group,pattern.type=pattern.type,pattern.line.size=pattern.line.size,
pattern.color=pattern.color,background.color=background.color,frame.color=frame.color, 
density=density,legend.h=2,legend.x.pos=1.1,legend.y.pos=0.495,legend.pixel=10, legend.w=0.2, 
legend.label=c("Orange", "Strawberry", "Watermelon"))

#Example 2
pattern.color=c('black','white', 'grey20')
background.color=c('gold','lightpink', 'lightgreen')
patternboxplot(data,x, y,group=group,pattern.type=pattern.type,pattern.line.size=pattern.line.size, 
pattern.color=pattern.color, background.color=background.color,frame.color=frame.color, 
density=density,legend.h=2,legend.x.pos=1.1,legend.y.pos=0.495,legend.pixel=10,legend.w=0.2, 
legend.label=c("Orange", "Strawberry", "Watermelon"))

patternplot documentation built on April 21, 2020, 5:05 p.m.