plot.kde {ks} | R Documentation |
Kernel density estimate plot for 2- and 3-dimensional data.
## bivariate ## S3 method for class 'kde': plot(fhat, display="slice", cont=c(25,50,75), ncont=NULL,cex=0.7, xlabs="x", ylabs="y", zlabs="Density function", theta=-30, phi=40, d=4, add=FALSE, drawlabels=TRUE, points.diff=TRUE, pch, ...) ## trivariate ## S3 method for class 'kde': plot(fhat, display="rgl", cont=c(25,50,75), colors, alphalo=0.2, alphahi=0.6, size=3, col="blue", add=FALSE, ...)
fhat |
an object of class kde i.e. output from
kde function |
display |
type of display, "slice" for contour plot, "persp" for perspective plot, "image" for image plot, "rgl" for RGL plot |
cont |
vector of percentages (of maximum height) for contour level curves |
ncont |
number of contour level curves |
cex,pch,xlabs,ylabs,zlabs,add |
usual graphics parameters |
theta,phi,d |
graphics parameters for perspective plots |
drawlabels |
draw contour labels |
points.diff |
not currently implemented |
colors |
vector of colours for each group |
alphalo, alphahi |
minimum and maximum transparency |
size,col |
size and colour for plotting symbol |
... |
other graphics parameters |
There are three types of plotting displays for 2-d data available, controlled
by the display
parameter.
If display="slice"
then a slice/contour plot
is generated using contour
.
The default contours are at 25%, 50%, 75% or
cont=c(25,50,75)
. The user can also set the number of contour
level curves by changing the value set to ncont
. See examples below.
If display="persp"
then a perspective/wire-frame plot
is generated. The default z-axis limits zlim
are determined by
the range of the z values i.e. default from the usual persp
command.
If display="image"
then an image plot
is generated. The colors are the default from the usual
image
command.
For 3-dimensional data, the interactive plot is a series of nested 3-d contours,
generated by the misc3d
and rgl
libraries. The default contours are cont=c(75,50,25)
, the
default colours are colors=rev(heat.colors(length(cont)))
and the
default opacity ranges between alphalo=0.2
and
alphahi=0.4
.
Plot of 2-d kernel density estimate is sent to graphics window. Plot for 3-d is sent to RGL window.
Bowman, A.W. & Azzalini, A. (1997) Applied Smoothing Techniques for Data Analysis. Clarendon Press. Oxford.
Simonoff, J. S., (1996) Smoothing Methods in Statistics. Springer-Verlag. New York.
### bivariate example data(unicef) H.scv <- Hscv(unicef) fhat <- kde(unicef, H.scv) layout(rbind(c(1,2), c(3,4))) plot(fhat, display="slice", cont=seq(10,90, by=20), cex=0.3) plot(fhat, display="slice", ncont=5, cex=0.3, drawlabels=FALSE) plot(fhat, display="persp") plot(fhat, display="image", col=rev(heat.colors(15))) layout(1) ### 3-variate example ## Not run: mus <- rbind(c(0,0,0), c(-1,1,1)) Sigma <- matrix(c(1, 0.7, 0.7, 0.7, 1, 0.7, 0.7, 0.7, 1), nr=3, nc=3) Sigmas <- rbind(Sigma, Sigma) props <- c(1/2, 1/2) x <- rmvnorm.mixt(n=100, mus=mus, Sigmas=Sigmas, props=props) H.pi <- Hpi(x) fhat <- kde(x, H.pi) plot(fhat) ## End(Not run)