tricolor: Provides smooth unit colors for SOMs

View source: R/tricolor.R

tricolorR Documentation

Provides smooth unit colors for SOMs


Function provides colour values for SOM units in such a way that the colour changes smoothly in every direction.


tricolor(grid, phis = c(0, 2 * pi/3, 4 * pi/3), offset = 0)



An object of class somgrid, such as the grid element in a kohonen object.


A vector of three rotation angles. Values for red, green and blue are given by the y-coordinate of the units after rotation with these three angles, respectively. The default corresponds to (approximate) red colour of the middle unit in the top row, and pure green and blue colours in the bottom left and right units, respectively. In case of a triangular map, the top unit is pure red.


Defines the minimal value in the RGB colour definition (default is 0). By supplying a value in the range [0, .9], pastel-like colours are provided.


Returns a matrix with three columns corresponding to red, green and blue. This can be used in the rgb function to provide colours for the units.

See Also



som.wines <- imputeSOM(wines, grid = somgrid(5, 5, "hexagonal"))

colour1 <- tricolor(som.wines$grid)
plot(som.wines, "mapping", bg = rgb(colour1))
colour2 <- tricolor(som.wines$grid, phi = c(pi/6, 0, -pi/6))
plot(som.wines, "mapping", bg = rgb(colour2))
colour3 <- tricolor(som.wines$grid, phi = c(pi/6, 0, -pi/6), offset = .5)
plot(som.wines, "mapping", bg = rgb(colour3))

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

Related to tricolor in missSOM...