plot.constr.hclust {adespatial}R Documentation

Plotting Method For Space- And Time-Constrained Clustering

Description

Method plot.constr.hclust displays the results of space-constrained or time-constrained agglomerative cluster analyses obtained from multivariate dissimilarity matrices.

Usage

## S3 method for class 'constr.hclust'
plot(x, k, xlim, ylim, xlab, ylab, links,
points=TRUE, pch=21L, hybrids=c("change","single","none"), lty.hyb=1L,
lwd.hyb=1, col.hyb="black", plot=TRUE, col, axes, cex=1, lty, lwd, lwd.pt=1,
invert.axes=FALSE, ...)

Arguments

x

A constr.hclust-class object

k

The number of clusters to delineate

xlim

Limits, in abscissa, of the zone to be plotted

ylim

Limits, in ordinate, of the zone to be plotted

xlab

Labels for x axis annotation

ylab

Labels for y axis annotation

links

Should segments be drawn to represent the edges (links) (default: FALSE)

points

Should observation points be drawn (default: TRUE)

pch

Point character to display observations (default: 21, a circle with a background color)

hybrids

How should hybrid segments be drawn (default: "change")

lty.hyb

Line type to use for hybrid segments (default: lty)

lwd.hyb

Width of hybrid segments with respect to lwd (default: 1)

col.hyb

Colour of hybrid segments, when applicable (default: "black")

plot

Should a new plotting window be opened first (default: TRUE)

col

Colours to use for the k different clusters (see details). Default: col=rainbow)

axes

Should the axes be displayed (default: TRUE)

cex

Text and symbol magnification (see graphical parameters) (default: 1)

lty

Reference line type (see graphical parameters for details)

lwd

Reference line width (see graphical parameters for details)

lwd.pt

Line width around points with respect to lwd (default: 1)

invert.axes

Should axes be inverted on the plot (default: FALSE)

...

Other graphical parameters

Details

The plotting method uses the coordinates provided by the user of constr.hclust to display the observations. It cuts the tree (see cutree) into k clusters and uses the colours provided by the user as argument col to display each cluster using the indices returned by cutree. When links = TRUE, each edge is displayed as a segments with colours corresponding to the clusters at its two ends. A special treatment is done for hybrids edges: those whose ends lie in different clusters; it is controlled by argument hybrids. When argument hybrids="change" (the default), hybrid links are represented as segments whose colours change halfway. When hybrids="single", hybrid edges are shown as single-color lines, whose color is given as argument col.hyb, whereas hybrids="none" suppresses the drawing of hybrid edges. Whenever hybrid edges are displayed, their width with respect to the lwd value is controlled by argument lwd.hyb.

When argument plot=FALSE, no plot command is issued and the points (and segments when links = TRUE) are drawn over an existing plotting window. This functionality is to allow one to plot the result of a constrained clustering over an existing map. In that case, arguments xlim, ylim, axes, and all other graphical parameters to which the method plot would responds are ignored.

The default colours are generated by function rainbow; see palette for further details on using colour palettes in R. The colour palette can be changed by the user.

Author(s)

Guillaume Guénard guillaume.guenard@umontreal.ca and Pierre Legendre pierre.legendre@umontreal.ca

Examples

##
### Artificial map data from Legendre & Legendre (2012, Fig. 13.26)
### n = 16
##
dat <- c(41,42,25,38,50,30,41,43,43,41,30,50,38,25,42,41)
coord.dat <- matrix(c(1,3,5,7,2,4,6,8,1,3,5,7,2,4,6,8,
                      4.4,4.4,4.4,4.4,3.3,3.3,3.3,3.3,
                      2.2,2.2,2.2,2.2,1.1,1.1,1.1,1.1),16,2)
##
### Obtaining a list of neighbours:
library(spdep)
listW <- nb2listw(tri2nb(coord.dat), style="B")
links.mat.dat <- listw2mat(listW)
neighbors <- listw2sn(listW)[,1:2]
##
### Calculating the (Euclidean) distance between points:
D.dat <- dist(dat)
##
### Display the points:
plot(coord.dat, type='n',asp=1)
title("Delaunay triangulation")
text(coord.dat, labels=as.character(as.matrix(dat)), pos=3)
for(i in 1:nrow(neighbors))
    lines(rbind(coord.dat[neighbors[i,1],],
          coord.dat[neighbors[i,2],]))
##
### Clustering with a contiguity constraint described by a list of
### links:
grpWD2cst_constr_hclust <-
    constr.hclust(
        D.dat, method="ward.D2",
        neighbors, coord.dat)
##
### Plot the results with k=5 clusters on a map:
plot(grpWD2cst_constr_hclust, k=5, links=TRUE, las=1,
     xlab="Eastings", ylab="Northings", cex=3, lwd=3)
##
### Repeat the plot with other values of k (number of groups)


[Package adespatial version 0.3-14 Index]