View source: R/np_plotting_functions.R
addNicePoints | R Documentation |
This function prepares data based on settings from niceBox
, niceDots
, or niceVio
and passes the data on to drawPoints
.
addNicePoints(
prepedData,
by,
filter = TRUE,
sidePlot = F,
subgroup = F,
plotAt,
pointHighlights = F,
pointMethod = "jitter",
pointShape = 16,
pointSize = 1,
width = 1,
pointLaneWidth = 0.9,
plotColors = formatPlotColors(list(1)),
drawPoints = T,
outliers = F,
dataCols = 1,
swarmOverflow = "random",
calcOnly = FALSE
)
prepedData |
list; a list object returned by |
by |
factor or dataframe of factors; One or more factors that control how the data is grouped. The first column is the primary grouping factor and the second and thrid columns are used for sub-grouping and highlighting as needed. |
filter |
logical vector; Used to further filter the data if necissary. |
sidePlot |
logical; switches the axis to plot horizontally instead of vertically. |
subgroup |
logical; Should the data be faceted into subgroups within the primary factor levels. Ignored if |
plotAt |
numeric; A vector of where to draw each set of points |
pointHighlights |
logical; will use additional factors in |
pointMethod |
character; method to be used for ploting dots. Can be set to "jitter", "linear", "beeswarm" or "distribution". |
pointShape |
positive integer; sets pty for plotting data points. Can be a vector to support additional graphical customization. |
pointSize |
positive integer; sets the cex multiplier for point size. |
width |
numeric; A multiplier that controls how wide the ploting elements will be. Setting |
pointLaneWidth |
numeric; This controls how far data point dots can move along the categorical axis when plotting. Used for |
plotColors |
list; a named list of vectors of colors that set the color options for all NicePlot functions. Names left unspecified will be added and set to default values automatically. |
drawPoints |
logical; draws a dot plot overlay of the data for each box. Setting this to false causes just the outlier points to be ploted. Used in |
outliers |
positive numeric; number of interquartile ranges (IQR) past the Q1 (25%) and Q3 (75%) cumulative distribution values. Outliers are often defined as |
dataCols |
numeric; A number of representing the number of data columns to be plotted. These is a combination of the dimentions of |
swarmOverflow |
character; How to handle beeswarms that would normally overflow the |
calcOnly |
logical; Will return just xy plotting data but will plot nothing if set to |
This function takes in cleaned data from prepCategoryWindow
and reorganizes to to create a dot plot overlay for a graph.
This code is used by both niceBox
and niceVio
and has been moved to an independent function to make the code more compact and easier to maintain.
This code is also used to draw the outlier dots in a boxplot by setting drawPoints = FALSE
.
drawPoints
, niceBox
, niceVio
, niceDots
, beeswarm
, jitter
, drawPoints
#Add a beeswarm plot overlay to a boxplot in the iris data set:
data(iris)
data<-list(data=iris$Sepal.Length)
boxplot(iris$Sepal.Length~iris$Species)
addNicePoints(data,by=iris$Species,pointMethod="beeswarm",plotAt=1:3)
#Add an outlier point to a boxplot:
boxplot(iris$Sepal.Length~iris$Species, outline=FALSE)
addNicePoints(data,by=iris$Species,pointMethod="linear",plotAt=1:3,
drawPoints=FALSE,outliers=1.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.