spreadPoints: Add spreaded, to avoid overlap, points to a boxplot

Description Usage Arguments Examples

View source: R/spreadPoints.R

Description

This function is similar to stripchart() function except it spreads points along an axis in a deterministic rather than random manner

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
spreadPoints(
  values,
  position,
  pointCex = 1,
  col = "black",
  pch = 19,
  alpha = 0.5,
  plotBins = FALSE,
  plotOutliers = FALSE,
  range = 1.5,
  horiz = FALSE,
  fitToBoxWidth = TRUE,
  xpd = FALSE,
  widthCex = 1
)

Arguments

values

A vector of numerical values

position

A numerical value indicating the position on the x-axis where values are to be plotted. Boxplots use integers: 1,2,3,...

pointCex

A numerical value giving the amount by which plotted symbols should be magnified relative to their default. Default value is 1

col

The colour of the points to be plotted. Defaults to black

pch

The shape of the points to be plotted

alpha

The transparency (0=transparent, 1=opaque). Default value is 0.5

plotBins

Boolean parameter indicating whether the bins used to spread to points should be plotted as horizontal lines

plotOutliers

Boolean parameter indicating whether to plot outliers. Outliers are defined as those outside range * InterQuartileRange. Defaults to FALSE

range

Numerical value used to determine outliers. Default value is 1.5 - same as used by boxplot function

horiz

Boolean parameter indicating whether boxplot was plotted horizontally. Default value is FALSE

fitToBoxWidth

Boolean parameter indicating whether the points are to spread only within the width of the box. Default value is TRUE

xpd

A Boolean value or NA. If FALSE, all plotting is clipped to the plot region, if TRUE, all plotting is clipped to the figure region, and if NA, all plotting is clipped to the device region

widthCex

A numerical value giving the amount by which amount the points are spread out should be magnified relative to their default. Default value is 1

Examples

1
2
3
4
5
6
7
8
9
# Generate some example points - drawn from exponential distribution
values <- rexp(n=50, rate=2)

# Plot a boxplot
boxplot(values, xlab="",  ylab="", frame=FALSE, las=1, pch=19, outcol=rgb(1,0,0, 0.5),
        horizontal=FALSE)

# Plot the points spread along the X axis
spreadPoints(values, position=1)

JosephCrispell/plotteR documentation built on June 6, 2021, 7:24 p.m.