Learn R Programming

LPCM (version 0.47-6)

plot.lpc: Plotting local principal curves and mean shift trajectories

Description

Takes an object of class lpc, lpc.spline or ms. In the case of principal curves, it plots any subset of the following components of the local principal curve: Centers of mass; the curve connecting the local centers of mass; the cubic spline representation of the curve; the projections onto the curve; the starting points. For the mean shift procedure, it produces a plot of mean shift trajectories and cluster centers.

Usage

# S3 method for lpc
plot(x, type, unscale = TRUE, lwd = 1, datcol = "grey60", 
    datpch = 21, masscol = NULL, masspch = 15, curvecol = 1, splinecol = 3, 
    projectcol = 4, startcol = NULL,  startpch=NULL,...)  
# S3 method for lpc.spline
plot(x, type, unscale = TRUE, lwd = 1, datcol = "grey60", 
    datpch = 21, masscol = NULL, masspch = 15, curvecol = 1, splinecol = 3, 
    projectcol = 4, startcol = NULL,  startpch=NULL,...)
# S3 method for ms
plot(x, unscale=FALSE, lwd=1, datcol="grey70",   datpch=21, masscol=NULL, 
    masspch=15, curvecol=NULL, ...)

Value

A plot of adequate dimensionality (depending on the type of object).

For local principal curves, the minimum supported dimension is \(d=2\), and for the mean shift it is \(d=1\). In either case, the maximum supported dimension is \(d=16\). With increasing dimension \(d\), less plotting options tend to be supported. The nicest plots are obtained for \(d=2\) and \(d=3\).

The most flexible plotting option is masscol. Depending on the length of the specified vector, this will be interpreted differently. If a scalar is provided, the corresponding color will be given to all centers of mass (or cluster centers). For LPCs, if the length of the vector is larger than 1, then this option will assign different colours to different depths, or different branch numbers, or to individual data points, depending on the length. The default setting is assigning colours according to depth, in the order red, blue, black.

Arguments

x

an object of class lpc, lpc.spline, or ms.

type

a vector of type c("mass", "spline",...) with possible entries mass, curve, spline, project, start.

unscale

if TRUE, then data (and all fitted components) are scaled back to their original scale; otherwise the scaled data are plotted (only relevant if scaled=TRUE in the fitted object). For ms, this is currently unimplemented.

lwd

width of principal curves or trajectories.

datcol

color of data points.

datpch

plotting symbol for data points.

masscol

color of centers of mass (see below) or cluster centers.

masspch

plotting symbol for centers of mass or cluster centers.

curvecol

color of the curve interpolating the local centers of mass (this is the "local principal curve"!).

splinecol

color of the spline representation of the local principal curve.

projectcol

color of projections onto the spline representation of the local principal curve.

startcol

color of the plotted starting points.

startpch

plotting symbol for starting points; needs to be either a single symbol, or a vector of symbols of the same length as the number of starting points.

...

further arguments passed to plot or scatterplot3d.

Warning

This function computes all missing information (if possible), so computation will take the longer the less informative the given object is, and the more advanced aspects are asked to plot!

Author

JE

References

Ameijeiras-Alonso, J. and Einbeck, J. (2023). A fresh look at mean-shift based modal clustering, Advances in Data Analysis and Classification, tools:::Rd_expr_doi("10.1007/s11634-023-00575-1").

Einbeck, J., Tutz, G., and Evers, L. (2005). Local principal curves. Statistics and Computing 15, 301-313.

Einbeck, J., Evers, L. & Hinchliff, K. (2010): Data compression and regression based on local principal curves. In A. Fink, B. Lausen, W. Seidel, and A. Ultsch (Eds), Advances in Data Analysis, Data Handling, and Business Intelligence, Heidelberg, pp. 701--712, Springer.

See Also

lpc, lpc.spline , ms

Examples

Run this code
data(calspeedflow)
lpc1 <- lpc(calspeedflow[,3:4])
plot(lpc1, type=c("spline","project"), lwd=2)
ms1<- ms(calspeedflow[,3:4], subset=sample.int(444,100), plot=FALSE) 
    # starts trajectories from 100 random obs'n
plot(ms1, masscol=1)
plot(ms1, curvecol="grey30")

data(mussels, package="dr")
ms2 <- ms(mussels[,-3], scaled=1, h=0.1, plot=FALSE)
plot(ms2, datpch=20, masspch=24)

Run the code above in your browser using DataLab