Last data update: 2014.03.03

R: Plot a Normal Curve with Shaded Intervals by Standard...
prob.znormR Documentation

Plot a Normal Curve with Shaded Intervals by Standard Deviation

Description

Display a normal curve with shading according to the z-score, the number of standard deviations from the mean.

Usage

prob.znorm(mu=0, sigma=1, color.border="gray10",
         r=.10, g=.34, b=.94, a=.20,
         xlab="", ylab="", main="", 
         y.axis=FALSE, z=TRUE, mag=.9, ...)

Arguments

mu

Population mean of normal distribution.

sigma

Population standard deviation of normal distribution.

color.border

Color of the border of the normal curve.

r

Red component of fill color, from 0 to 1.

g

Green component of fill color, from 0 to 1.

b

Blue component of fill color, from 0 to 1.

a

Alpha component of fill color, that is, the transparency, from 0 to 1.

xlab

Label for the horizontal axis.

ylab

Label for the optional vertical axis.

main

Label for the graph title.

y.axis

If TRUE, then a vertical axis is included.

z

If TRUE, then include z-values on the horizontal-axis. Set to FALSE if mu=0 and sigma=1.

mag

Magnification factor for the axis labels, the value of cex.axis.

...

Other parameter values for graphics.

Details

Provide a normal curve with shading of each interval defined by the number of standard deviations from the mean. The layers are written with transparency, and over-written so that the middle interval is the darkest and the most extreme intervals, beyond three standard deviations from the mean, are the lightest. Specify a=0 to turn off the colors. Higher values of the alpha channel, as specified by a, yield darker colors. Specify a=1 for the same solid color for all intervals.

The normal densities are calculated with dnorm and plotted with plot.

Author(s)

David W. Gerbing (Portland State University; gerbing@pdx.edu)

See Also

dnorm, plot.

Examples

# Mu=0, Sigma=1: Standard normal 
prob.znorm()

# distribution for height of American women, mu=65.5, sigma=2.5
prob.znorm(65.5, 2.5, xlab="Height of American Women")

# do a red fill color
prob.znorm(65.5, 2.5, r=.9, xlab="Height of American Women")

Results