plot.linkage: Plots for Extended Agglomerative Hierarchical Clustering

plot.linkageR Documentation

Plots for Extended Agglomerative Hierarchical Clustering

Description

Creates plots for visualizing an object of class "linkage".

Usage

## S3 method for class 'linkage'
plot(x, type = c("rectangle", "triangle"),
     center = FALSE, edge.root = FALSE,
     nodePar = NULL, edgePar = list(),
     leaflab = c("perpendicular", "textlike", "none"),
     dLeaf = NULL, xlab = "", ylab = "", xaxt = "n", yaxt = "s",
     horiz = FALSE, frame.plot = FALSE, xlim, ylim,
     col.rng = "lightgray", ...)

Arguments

x

An object of class "linkage", typically created by linkage().

type

Type of plot.

center

Logical; if TRUE, nodes are plotted centered with respect to the leaves in the branch. Otherwise (default), plot them in the middle of all direct child nodes.

edge.root

Logical; if true, draw an edge to the root node.

nodePar

A list of plotting parameters to use for the nodes (see points) or NULL by default which does not draw symbols at the nodes. The list may contain components named pch, cex, col, xpd, and/or bg each of which can have length two for specifying separate attributes for inner nodes and leaves. Note that the default of pch is 1:2, so you may want to use pch = NA if you specify nodePar.

edgePar

A list of plotting parameters to use for the edge segments. The list may contain components named col, lty and lwd. As with nodePar, each can have length two for differentiating leaves and inner nodes.

leaflab

A string specifying how leaves are labeled. The default "perpendicular" writes text vertically (by default), "textlike" writes text horizontally (in a rectangle), and "none" suppresses leaf labels.

dLeaf

A number specifying the distance in user coordinates between the tip of a leaf and its label. If NULL as per default, 3/4 of a letter width or height is used.

xlab, ylab

A label for the axis.

xaxt, yaxt

A character which specifies the axis type. Specifying "n" suppresses plotting, while any value other than "n" implies plotting.

horiz

Logical indicating if the dendrogram should be drawn horizontally or not.

frame.plot

Logical indicating if a box around the plot should be drawn, see plot.default.

xlim, ylim

Optional x- and y-limits of the plot, passed to plot.default. The defaults for these show the full dendrogram.

col.rng

Color ("lightgray" by default) to be used for plotting range rectangles in case of tied heights. If NULL, range rectangles are not plotted.

...

Graphical parameters (see par) may also be supplied and are passed to plot.default.

Details

Based on the plot function for objects of class "dendrogram" (see plot.dendrogram), the plot function for objects of class "linkage" adds the possibility of visualizing the existence of tied heights in a dendrogram thanks to the col.rng parameter.

See Also

linkage, dendrogram.

Examples

## Plot complete linkage of mtcars distances, showing and hiding ranges
mtcars.dist <- dist(scale(mtcars))  # distances of standardized data
lnk <- linkage(mtcars.dist, digits = 1, method = "complete")
par(mfrow = c(1, 2))
nodePar <- list(cex = 0, lab.cex = 0.4)
plot(lnk, col.rng = "bisque", main = "show ranges", nodePar = nodePar)
plot(lnk, col.rng = NULL, main = "hide ranges", nodePar = nodePar)

mdendro documentation built on May 29, 2024, 12:26 p.m.