drawPoints: draw dots for a dot plot

View source: R/np_plotting_functions.R

drawPointsR Documentation

draw dots for a dot plot

Description

takes a data frame of locations, values and an optional subgrouping factor and adds the data points to the active plot

Usage

drawPoints(
  x,
  type = "jitter",
  col = "black",
  size = 1,
  shape = 1,
  highlight = FALSE,
  width = 0.2,
  sidePlot = FALSE,
  swarmOverflow = "random",
  calcOnly = FALSE
)

Arguments

x

named list or data frame; x$at, x$data and x$pfact (optional) should all be defined. These vectors are used to place the the point on the chart and determine the point level grouping (highlighting)

type

character; determines how the points are arranged. Options are 'jitter', 'linear', 'beeswarm' and 'distribution'.

col

character; vector of color names for plotting points. If length is greater than one it will be used for subgroups or will iterate over the groups.

size

numeric; vector of cex values for point size. If length is greater than one it will be used for subgroups or will iterate over the groups.

shape

numeric; vector determining point shapes (pch). If length is greater than one it will be used for subgroups or will iterate over the groups.

highlight

logical; Should the point highlighting option be turned on (assumes that pfact is defined).

width

numeric; determines how far points can deviate from the center category label for type options other than 'linear'.

sidePlot

logical; plots dots for a horizontal rather than vertical axis.

swarmOverflow

character; How to handle beeswarms that would normally overflow the width argument. Valid options are "random", "gutter", "wrap", "omit", and "none".

calcOnly

logical; Will return just xy plotting data but will plot nothing if set to TRUE. Setting drawPoints to false will still plot outlier data.

Details

This function adds data points to a chart. These can be organized exactly as specified (linear), as a jitter cloud (jitter), as a waterfall plot (distribution) or as a swarm (beeswarm). A factor labeled pfact can be included in x and used to highlight individual data points by setting subgroup=TRUE. All graphic customization options can given as vectors and will be iterated over during plotting. Note that the size/cex option can not be used to highlight pfact levels in a beeswarm plot and only the first element of the vector will be used. The function silently returns the final xy positions.

See Also

points, stripchart, beeswarm

Examples

data(iris)
boxplot(iris$Sepal.Length~iris$Species,ylab="Sepal Length")
iData<-data.frame(at=as.numeric(iris$Species),data=iris$Sepal.Length)
drawPoints(iData,type="jitter",col=c("red","blue","purple"))

ZachHunter/NicePlots.R documentation built on Sept. 23, 2023, 4:04 a.m.