som.plot: Function to plot hexagonal Kohonen maps

Description Usage Arguments Value Author(s) References Examples

View source: R/somplot.R


The function plots hexagonal self-organising maps (SOMs), which have been created with Teuvo Kohonen's SOM_PAK software.

The plot shows an hexagonal lattice representing the codebook vectors of the SOM. Inside each hexagon a pie chart is drawn, showing the relative percentage of pattern classes, mapped to this codebook vector. The size of each pie chart is adjusted according to the number of mapped patterns.

Several arguments allow customisation of size, scale and colouring of the plot.

The function needs two files of the SOM_PAK file set:


som.plot(visfile, datfile, ...)



Name of the output file of visual. visual is the tool of SOM_PAK which maps pattern to the codebook vectors of a self-organising map.\ The function reads files in the format created by visual.


Name of the SOM_PAK input file. This files contains all input patterns and class information for each pattern. som-plot only uses the last colums of the file; i.e. the class information for each pattern.\ The function reads files in the format that is used by SOM_PAK.


Many other arguments can be given to control the appearence of the plot:

‘col’, default colours for the classes of the dataset. Possible values include:

‘default value: NA.’ Colours are generated by rainbow()

‘vector’ of colour definitions

‘data frame’ with name of a class in column 1 and colour definitions in column 2.

If the number of defined colours is smaller then the number of classes in the dataset, colours for the remaining classes are generated by rainbow.

‘onlyDefCols’ default: FALSE; if TRUE, all undefined colours are replaced by white

‘edit.cols’ default: FALSE; if TRUE, a dialog box opens and allows editing of all color definitions

‘show.legend’ default: TRUE; defines if colour legend is displayed

‘legend.width’ default: 4; Width of legend

‘turn’ default: FALSE; swap X and Y axis

‘window.width’ default: NA; width of the window

‘window.height’ default: NA; height of the window

‘’ default: TRUE; show frame around the plot

‘show.axis’ default: FALSE; show x and Y axis

‘scaleX’ default: NA; scale factor for X axis (overwrites new.xdim argument)

‘scaleY’ default: NA; scale factor for Y axis (overwrites new.ydim argument)

‘scale’ default: NA; scale factor for X and Y axis (overwrites other scale argument)

‘new.xdim’ default: NA; scale X axis to specified number of neurons

‘new.ydim’ default: NA; scale Y axis to specified number of neurons

‘show.counter.border’ default: 0.98 percentile as limit for the display of labels in the pie charts


The function does not returns a value.


Benjamin Schulz, Andreas Dominik


Schulz, B., Mauthe, T., Dominik, A., 2010. Visualisation of Kohonen Maps using R. THM University of Applied Sciences, Giessen, Germany Website, [Online]. Available at: [Accessed 19 May 2011]. and


som.plot(system.file("", package="somplot"), 
         system.file("", package="somplot"))

Example output

Loading required package: hexbin

somplot documentation built on May 30, 2017, 4:30 a.m.