spreadPointsMultiple: 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
16
spreadPointsMultiple(
  data,
  responseColumn,
  categoriesColumn,
  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

data

A dataframe object containing the data to be plotted

responseColumn

The name or index of the response data (Y)

categoriesColumn

The name or index of the column that categorises the response data

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
# Generate some example points - drawn from normal distribution and randomly assign them to categories
randomSamples <- data.frame(Values = rnorm(500), Category = sample(c('A', 'B', 'C', 'D', 'E'), size=500, replace=TRUE))

# Plot a boxplot of the samples from the normal distribution versus there categories - multiple boxplots
boxplot(Values ~ Category, data = randomSamples, lwd = 2)

# Plot the points for each category spread along the X axis
spreadPointsMultiple(data=randomSamples, responseColumn="Values", categoriesColumn="Category")

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