ggPlotMultiDensities {DiPALM}R Documentation

Plot multiple density distributions

Description

This function generates one or more smoothed density distributions using ggplot2 functionality

Usage

ggPlotMultiDensities(denslist, main = "", xlab = "", ylab = "Normalized Frequency",
 scale = T, cols = c("red", "blue", "grey50", "black", "skyblue", "orange"),
 ledgx = "topright", ltype = NULL, lwidth = NULL, xrng = NULL, yrng = NULL, Ledge = T)

Arguments

denslist

A named list of populations. Each element is a vector of numbers. A separate density plot will be generated for each population.

main

The main plot title.

xlab

The x-axis label.

ylab

The y-axis label.

scale

When multiple densities are plotted, should they be scaled to represent the relative number of samples in each population.

cols

A vector of colors (one for each population in denslist).

ledgx

The x value from legend function. Determines where the legend is plotted.

ltype

A vector of integers specifying the line types to be used for each population (repeated if necessary for multiple populations).

lwidth

The line width to be used in the plot.

xrng

A numeric vector of 2, the x-axis range to be plotted.

yrng

A numeric vector of 2, the y-axis range to be plotted.

Ledge

A logical: should the legend be plotted?

Details

This function takes in a list of one or more numeric vectors. Each vector is considered a separate population and a smoothed density plot (similar to a histogram) will be generated for each and plotted together. The actual numeric y-axis values are meaningless. A density plot is normalized so that the total area under the curve is equal to 1. When scale = T, the total area under the density plots may not equal one, but instead the total area is scaled to the relative proportions of the total population sizes of each population.

Value

Generates multiple density plots on the same graph.

Author(s)

Ryan C. Sartor

See Also

ggplot2

Examples

data(testData)
require(ggplot2)

# Two populations of the same size, unscaled
ggPlotMultiDensities(denslist = list(Test=testData$testResults,Permuted=testData$permutedResults),
main = "Pattern Change Scores", xlab = "Differential Pattern Score",lwidth = 1)

# Two populations of different sizes, scaled
ggPlotMultiDensities(denslist = list(Test=testData$testResults[1:3000],
Permuted=testData$permutedResults), scale=TRUE , main = "Pattern Change Scores (Scaled)",
xlab = "Differential Pattern Score",lwidth = 1)


[Package DiPALM version 1.2 Index]