Learn R Programming

Momocs (version 0.2-6)

dudi.plot: A wrapper for dudi.pca graphical functions.

Description

A wrapper for dudi.pca objects produced by dudi.pca in ade4 or pca in Momocs.

Usage

dudi.plot(dudi, fac = NULL, xax = 1, yax = 2, grid = TRUE,
	points = TRUE, pch.points = 1, col.points = "black", cex.points = 0.8,
	labels = FALSE, label = rownames(dudi$li),
	boxes = TRUE, clabel = 0.6,
	neighbors = FALSE, col.nei = "grey90", lwd.nei = 0.5,
	star = TRUE, col.star = "grey60", cstar = 1,
	ellipses = TRUE, col.ellipse = "grey30", cellipse = 1, axesell = TRUE,
	chull = FALSE, col.chull = "grey30", optchull = c(0.5, 1),
	arrows = FALSE, edge.arrow = FALSE,
	        box.arrow = TRUE, maxnb.arrow = 10, dratio.arrow = 0.2,
	shapes = TRUE, pos.shp=c("li", "circle", "range", "full")[3], 
		nr.shp = 6, nc.shp = 5, amp.shp = 1,
		scale.shp = 0.666, nb.pts.shp=300,
		first.point.shp = FALSE, rotate.shp=0,
		circle.nb.shp = 12, circle.r.shp,
		col.shp = "#70809011", border.shp = "#708090",
	rug = TRUE, rug.ticksize = 0.01, rug.col = "#708090",
	eigen = FALSE, eigen.ratio = 0.2,
	palette = col.sari, title = substitute(dudi), legend=FALSE,
	center.orig = FALSE, zoom.plot = 1)

Arguments

dudi
a dudi.pca object.
fac
the (col)name of the @fac slot to use as the grouping factor.
xax
integer. The index of the first PC axis to use.
yax
integer. The index of the first PC axis to use.
grid
logical. Whether to draw the grid.
points
logical. Whether to draw the points.
pch.points
the pch for drawing points.
col.points
the col for drawing points.
cex.points
the cex for drawing points.
labels
logical. Whether to draw labels.
label
character. The labels to draw.
boxes
logical. Whether to draw labels in boxes.
clabel
The cex for labels.
neighbors
logical. Whether to draw a neighboring graph.
col.nei
the col for drawing neighboring graph.
lwd.nei
the lwd for drawing neighboring graph.
star
logical. Whether to draw the star.
col.star
the col for drawing the star.
cstar
numeric. The size of the star.
ellipses
logical. Whether to draw bivariate confidence ellipses.
col.ellipse
The col for drawing these ellipses.
cellipse
numeric. The size of this ellipse.
axesell
logical. Whether to draw the ellipses axes.
chull
logical. Whether to draw a convex hull.
col.chull
The col for drawing convex hulls.
optchull
numeric. A vector of quantiles of the chulls.
arrows
logical. Whether to draw variables arrows.
edge.arrow
logical. Whether to neutralise arrows.
box.arrow
logical. Whether to draw boxes around arrows' labels.
maxnb.arrow
numeric. Only the maxnb.arrow most important variables will be draw.
dratio.arrow
numeric. Same idea as above but here the threshold is a relative to the size of the grid.
shapes
logical. Whether to plot shapes.
pos.shp
character, any of the ("li", "circle", "range") methods. It specifies the way shapes have to be drawn. "li" draws shapes on the actual positions on the factorial map ; "circle" draws shapes on a circle w
nr.shp
numeric. The number of shape rows.
nc.shp
numeric. The number of shape columns.
amp.shp
numeric. An amplifying factor for shape deformation.
scale.shp
numeric. The size of shapes, relatively to grid size (0.5 = half of the grid size).
nb.pts.shp
numeric. The number of point to use to reconstruct shapes.
first.point.shp
logical. Whether to plot or not the first point when plotting shapes.
rotate.shp
numeric. If specified, the angles (in radians) to counter-clockwise rotate shapes plotted.
circle.nb.shp
integer. When pos == "circle", the number of shapes on the circle.
circle.r.shp
numeric. When pos == "circle", the circle radius.
col.shp
A color string for filling the shapes.
border.shp
A color string for shape borders.
rug
logical. Whether to add rug on axes (see rug).
rug.ticksize
numeric. The relative size of rug.
rug.col
A color string for rug ticks.
eigen
logical. Whether to add the eigen values barplot.
eigen.ratio
numeric. The relative size of the eigen values barplot.
palette
A color palette for group colors such as those produced by colorRampPalette.
title
A character string to be add on the graph.
legend
logical. Whether to add or not a legend.
center.orig
logical. Whether to center the graphical window on the origin.
zoom.plot
numeric. Will help you to keep your distances, e.g. the value of magnification. Requires center.orig to be set true.

Details

This function takes the slightly modified dudi.pca object, obtained with pca on a Coe object and widely hinges on ade4 plotting facilities and graphical layers. Notice that besides dedicated shapes argument and options, it can be used for plotting factorial maps on "regular" dudi.pca objects. By default, shapes is set to FALSE for tFourier analyses since the reconstruction of shapes do not always lead to closed shapes (see Rohlf F, Archie J. 1984. A comparison of Fourier methods for the description of wing shape in mosquitoes (Diptera: Culicidae). Systematic Biology: 302-317.).

References

See the papers below that introduce ade4 and also the package's homepage: http://pbil.univ-lyon1.fr/ADE-4/ and particularly the file called "td83" : Lobry JR. 2010. Les fonctions graphiques 2D du paquet ade4. Dray, S. and Dufour, A.B. (2007): The ade4 package: implementing the duality diagram for ecologists. Journal of Statistical Software. 22(4): 1-20. Chessel, D. and Dufour, A.B. and Thioulouse, J. (2004): The ade4 package-I- One-table methods. R News. 4: 5-10. Dray, S. and Dufour, A.B. and Chessel, D. (2007): The ade4 package-II: Two-table and K-table methods. R News. 7(2): 47-52.

See Also

pca, morpho.space.

Examples

Run this code
data(bot)
botF <- eFourier(bot, nb.h=32)
botD <- pca(botF)
dudi.plot(botD)
dudi.plot(botD, 1, title="botD with no class but with ellipses")
dudi.plot(botD, fac=1, chull=TRUE, rug=FALSE, shape=FALSE, title="botD with convex hull")
dudi.plot(botD, fac=1, ellipses=FALSE, neighbors=TRUE, shapes=FALSE, star=FALSE,
	col.nei="black", title="botD with Gabriel's neighboring graph")
dudi.plot(botD, labels=TRUE, points=FALSE, boxes=FALSE, shapes=TRUE, pos.shp="li",
	title="botD with labels and reconstructed shapes")
dudi.plot(botD, 1, points=FALSE, labels=TRUE, boxes=FALSE, shapes=FALSE,
	title="botD with labels and ellipse")
dudi.plot(botD, 1, arrows=TRUE, dratio.arrow=0.2, shapes=FALSE,
	title="botD with harmonic correlations")
# With some fake factors
botD <- pca(botF)
dudi.plot(botD, "type", palette=col.gallus,
    rotate.shp=pi/2, title="botD with classes") # rotated shapes
dudi.plot(botD, "type", palette=col.gallus, eigen=TRUE, title="botD with eigen values")
dudi.plot(botD, "type", pos.shp="full", title="botD with shapes(1)")
dudi.plot(botD, "type", pos.shp="range", scale.shp=0.5, shapes=TRUE,
	border.shp="firebrick3", col.shp=NA, center.orig=TRUE, 
	zoom.plot=0.8, title="botD with shapes(2)")
dudi.plot(botD, "type", pos.shp="circle", center.orig=TRUE, title="botD with shapes(3)")
dudi.plot(botD, "type", pos.shp="range", scale.shp=0.5, title="botD with shapes(4)")
dudi.plot(botD, pos.shp=as.matrix(expand.grid(seq(-0.05, 0.05, 0.025),
    seq(-0.05, 0.05, 0.025)))) # an example with a matrix provided to pos.shp

Run the code above in your browser using DataLab