plot.somgrid: Plot a Self-Organising Map prior structure

Description Usage Arguments Details Author(s) References Examples

Description

Plot the prior structure used by a Self-Organizing Map. The rendering is glyph based. Rectangular grids use square glyphs while hexagonal grids use hexagons (the generic term is cell). Glyph positioning is fixed (according to the prior structure) but glyph size and color can be used to encode different type of results.

Usage

1
2
3
4
## S3 method for class 'somgrid'
plot(x, col = NA, size = NA, add = FALSE, border = NULL,
   colorValues = NA, sizeValues = NA, colormap = 50, withkey = FALSE,
   color.palette = heat.colors, ...)

Arguments

x

an object of class somgrid

col

colors of the cells

size

sizes of the cells (must be between 0 and 1, inclusive)

add

logical. If TRUE, add to a current plot

border

the color to draw the border. The default, NULL, means to use par("fg"). Use border = NA to omit borders.

colorValues

a vector containing the values to be used for calculating the colors of the cells. If specified, this takes precedence over the col parameter. The color mapping is linear.

sizeValues

a vector containing the values to be used for calculating the size of the cells. If specified, this takes precedence over the size parameter. The surface of each cell will be proportional to the square root of the corresponding value.

colormap

if an integer, gives the number of colors to be generated by color.palette for the coloring of the cells with colorValues. Alternatively, a vector of colors to use in conjunction with colorValues

withkey

logical. If TRUE add a key to the plot (incompatible with add=TRUE). See details

color.palette

a color palette function to be used to assign colors to the glyphs (defaults to heat.colors)

...

additional parameters transmitted to the low level plot function (i.e., polygon for hexagonal grids and rect for rectangular grids)

Details

When asked for a key, this function uses the layout facilities. It is therefore incompatible with other device splitting functions (par(mfrow), par(mfcol) and split.screen).

Author(s)

Fabrice Rossi

References

Vesanto, J. (2002) Data Exploration Process Based on the Self–Organizing Map, PhD thesis, Helsinki University of Technology, Espoo (Finland), Acta Polytechnica Scandinavica, Mathematics and Computing Series No. 115.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
data(iris)
# scaling
data <- scale(iris[1:4])

# a medium hexagonal grid
sg <- somgrid(xdim=15,ydim=15,topo="hex")

# empty grid
plot(sg)

# choose a good SOM
som <- som.tune(data,sg)$best.som

# color based on the first coordinate (sepal length), size on the second
# (sepal width) of the prototypes
plot(sg,colorValues=som$prototypes[,1],sizeValues=som$prototypes[,2],
     withkey=TRUE)

# color based on the dominant class
col <- rep(NA,sg$size)
classes <- sapply(mapToUnit(som,iris[[5]]),summary)
col[colSums(classes)!=0] <-
    c("red","blue","green")[apply(classes[,colSums(classes)!=0],2,which.max)]
plot(sg,col=col)

yasomi documentation built on May 2, 2019, 5:59 p.m.