Shade

0th

Percentile

Produce a Shaded Curve

Sometimes the area under a density on a graphic has to be color shaded, for instance to illustrate a p-value or a region under the normal curve. This function offers a function interface for doing this with less code.

Keywords
aplot
Usage
Shade(FUN, col = par("fg"), xlim, density = 10, step = 0.01, ...)
Arguments
FUN
the function to be evaluated, best given as text: FUN="f(x)".

col
color to fill or shade the shape with. The default is taken from par("fg").

xlim
range of the x-range.

density
the density of the lines as needed in polygon.

step
the step for the x-values to be used for calculating the function values.

...
the dots are passed on to polygon.

Details

Useful for shading the area under a curve as often needed for explaining significance tests.

Value

See Also

polygon

Aliases
  • Shade
Examples
curve(dt(x, df=5), xlim=c(-6,6),
      main=paste("Student t-Distribution Probability Density Function, df = ", 5, ")", sep=""),
      type="n", las=1, ylab="probability", xlab="t")

Shade(FUN="dt(x, df=5)", xlim=c(-6, qt(0.025, df=5)), col="red")
Shade(FUN="dt(x, df=5)", xlim=c(qt(0.025, df=5), qt(0.975, df=5)), col="green")
Shade(FUN="dt(x, df=5)", xlim=c(qt(0.975, df=5), 6), col="red")
Documentation reproduced from package DescTools, version 0.99.19, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.