plot.dtrace {dtrace}R Documentation

Plot a Density Trace Object

Description

This function provides a plot method for objects of class dtrace, such as those created by dtrace.

Usage

## S3 method for class 'dtrace':
plot(x,
  col = NULL, lty = 1:length(x$density), lwd = NULL,
  main = "", xlab = "", ylab = "Density", log = "", las = par("las"),
  add = FALSE, draw.legend = length(x$density) > 1 && !add,
  ...)

Arguments

x An object of class dtrace.
col Colors for the lines.
lty Line textures (recycled if required).
lwd Line widths (recycled if required).
main An overall title for the plot.
xlab A label for the x axis.
ylab A label for the y axis.
log A character string indicating which axes should be shown on a log scale. The default is "".
las Desired axis label style.
add If true, the density traces are drawn on an existing plot, otherwise a new plot is created.
draw.legend Should a legend be added to the plot?
... Additional arguments which are passed to legend so that the legend can be customized.

Details

This function produces a plot of density trace object. The plot can show a either single density or several superimposed densities. In the latter case, a legend is printed on the plot indicating which density is which. By default, different line textures are used to distinguish the densities but it is also possible to vary colors and line thicknesses.

The plots produced by this function have minimal annotation. This is deliberate because, when several densities are superimposed, it is not clear what should be written on the plot. The density trace summary function can be used to obtain information about the density extimates which could be written onto the plot.

Value

The value of the argument x is returned as the invisible value of this function.

Author(s)

Ross Ihaka

See Also

dtrace.

Examples

## Estimation and plotting of three densities.
## A demonstration of the formula-based interface.
data(iris)
d <- dtrace(Petal.Width ~ Species, data = iris)
plot(d, lty = 1, col=c("red","green4", "blue"),
     legend = c("Setosa", "Versicolor", "Virginica"),
     main = "The Distribution of Iris Petal Width",
     xlab = "Petal Width (cm)")

[Package dtrace version 0.1 Index]