som.plot: Function to plot hexagonal Kohonen maps

Description Usage Arguments Value Author(s) References Examples


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:

  • The output of visual provides the mapping of input patterns to the codebook vectors.

  • The input file holding the mapped dataset with class information in the last column.


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"))

Search within the somplot package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.