plot.missSOM: Plot missSOM object

plot.missSOMR Documentation

Plot missSOM object


Plot objects of class missSOM. Several types of plots are supported.


## S3 method for class 'missSOM'
  type = c("codes", "changes", "counts", "dist.neighbours", "mapping", "property",
  classif = NULL,
  labels = NULL,
  pchs = NULL,
  main = NULL, = NULL,
  bgcol = NULL,
  zlim = NULL,
  heatkey = TRUE,
  codeRendering = NULL,
  keepMargins = FALSE,
  heatkeywidth = 0.2,
  shape = c("round", "straight"),
  border = "black",
  na.color = "gray",

add.cluster.boundaries(x, clustering, lwd = 5, ...)

## S3 method for class 'missSOM'
identify(x, ...)



missSOM object.


type of plot. (Wow!)


classification object or vector of unit numbers. Only needed if type equals "mapping" and "counts".


labels to plot when type equals "mapping".


symbols to plot when type equals "mapping".


title of the plot.

colors to use as unit background for "codes", "counts", "prediction", "property", and "quality" plotting types.


number of colors to use for the unit backgrounds. Default is 20 for continuous data.


optional argument to colour the unit backgrounds for the "mapping" and "codes" plotting type. Defaults to "gray" and "transparent" in both types, respectively.


optional range for color coding of unit backgrounds.


whether or not to generate a heatkey at the left side of the plot in the "property" and "counts" plotting types.


values to use with the "property" plotting type.


How to show the codes. Possible choices: "segments", "stars" and "lines".


if FALSE (the default), restore the original graphical parameters after plotting the kohonen map. If TRUE, one retains the map coordinate system so that one can add symbols to the plot, or map unit numbers using the identify function.


width of the colour key; the default of 0.2 should work in most cases but in some cases, e.g. when plotting multiple figures, it may need to be adjusted.


kind shape to be drawn: "round" (circle) or "straight". Choosing "straight" produces a map of squares when the grid is "rectangular", and produces a map of hexagons when the grid is "hexagonal".


color of the shape's border.


background color matching NA - default "gray".


other graphical parameters.


cluster labels of the map units.


other graphical parameters.


Several different types of plots are supported:


shows the mean distance to the closest codebook vector during training.


shows the codebook vectors.


shows the number of objects mapped to the individual units. Empty units are depicted in gray.


shows the sum of the distances to all immediate neighbours. This kind of visualisation is also known as a U-matrix plot. Units near a class boundary can be expected to have higher average distances to their neighbours.


shows where objects are mapped. It needs the "classif" argument, and a "labels" or "pchs" argument.


properties of each unit can be calculated and shown in colour code. It can be used to visualise the similarity of one particular object to all units in the map, to show the mean similarity of all units and the objects mapped to them, etcetera. The parameter property contains the numerical values. See examples below.


shows the mean distance of objects mapped to a unit to the codebook vector of that unit. The smaller the distances, the better the objects are represented by the codebook vectors.

Function identify.missSOM shows the number of a unit that is clicked on with the mouse. The tolerance is calculated from the ratio of the plotting region and the user coordinates, so clicking at any place within a unit should work.

Function add.cluster.boundaries will add to an existing plot of a map thick lines, visualizing which units would be clustered together. In toroidal maps, boundaries at the edges will only be shown on the top and right sides to avoid double boundaries.


Several types of plots return useful values (invisibly): the "counts", "dist.neighbours", and "quality" return vectors corresponding to the information visualized in the plot (unit background colours and heatkey).

See Also



set.seed(7) <- imputeSOM(scale(wines), grid = somgrid(5, 5, "hexagonal"), rlen=100)
plot(, type="changes")
counts <- plot(, type="counts", shape = "straight")
## show both sets of codebook vectors in the map
plot(, type="codes", main = c("Codes X"))

oldpar <- par(mfrow = c(1,2))
similarities <- plot(, type="quality", = terrain.colors)
plot(, type="mapping", 
     labels = as.integer(vintages), col = as.integer(vintages), 
     main = "mapping plot")

## Show 'component planes'
sommap <- imputeSOM(scale(wines), grid = somgrid(6, 4, "hexagonal"))
plot(sommap, type = "property", property = sommap$codes[,1], 
     main = colnames(sommap$codes)[1])

## Show the U matrix
Umat <- plot(sommap, type="dist.neighbours", main = "SOM neighbour distances")
## use hierarchical clustering to cluster the codebook vectors
som.hc <- cutree(hclust(object.distances(sommap, "codes")), 5)
add.cluster.boundaries(sommap, som.hc)

## and the same for rectangular maps
sommap <- imputeSOM(scale(wines),grid = somgrid(6, 4, "rectangular"))
plot(sommap, type="dist.neighbours", main = "SOM neighbour distances")
## use hierarchical clustering to cluster the codebook vectors
som.hc <- cutree(hclust(object.distances(sommap, "codes")), 5)
add.cluster.boundaries(sommap, som.hc)

missSOM documentation built on May 5, 2022, 9:06 a.m.