kohonen (version 3.0.8)

tricolor: Provides smooth unit colors for SOMs

Description

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

Usage

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

Arguments

grid

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

phis

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.

offset

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.

Value

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

plot.kohonen

Examples

Run this code
# NOT RUN {
data(wines)
som.wines <- som(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))
# }

Run the code above in your browser using DataCamp Workspace