, , . , ,

, kohonen. : http://nbremer.blogspot.nl/2013/07/on-creation-of-extended-self-organizing.html
, : <<Heatmap matrix variable>> - , .
[1,1] node (1- , 1- ), [1,2] node , [2,1] node ..
, Heatmap,
library(RColorBrewer)
library(fields)
Hexagon <- function (x, y, unitcell = 1, col = col) {
polygon(c(x, x, x + unitcell/2, x + unitcell, x + unitcell,
x + unitcell/2), c(y + unitcell * 0.125, y + unitcell *
0.875, y + unitcell * 1.125, y + unitcell * 0.875,
y + unitcell * 0.125, y - unitcell * 0.125),
col = col, border=NA)
}
x <- as.vector(<<Heatmap matrix variable>>)
SOM_Rows <- dim(<<Heatmap matrix variable>>)[1]
SOM_Columns <- dim(<<Heatmap matrix variable>>)[2]
par(mar = c(0.4, 2, 2, 7))
plot(0, 0, type = "n", axes = FALSE, xlim=c(0, SOM_Columns),
ylim=c(0, SOM_Rows), xlab="", ylab= "", asp=1)
ColRamp <- rev(designer.colors(n=50, col=brewer.pal(9, "Spectral")))
ColorCode <- rep("#FFFFFF", length(x))
Bins <- seq(min(x, na.rm=T), max(x, na.rm=T), length=length(ColRamp))
for (i in 1:length(x))
if (!is.na(x[i])) ColorCode[i] <- ColRamp[which.min(abs(Bins-x[i]))]
offset <- 0.5
for (row in 1:SOM_Rows) {
for (column in 0:(SOM_Columns - 1))
Hexagon(column + offset, row - 1, col = ColorCode[row + SOM_Rows * column])
offset <- ifelse(offset, 0, 0.5)
}
image.plot(legend.only=TRUE, col=ColRamp, zlim=c(min(x, na.rm=T), max(x, na.rm=T)))