我目前正致力于SOM vizualisations。
这是一张SOM地图,其中包含使用kohonen包生成的代码图 不久,每个圆圈都是神经元,在每个神经元内部,我们绘制光谱形状中的所有变量。 这个图是通过som_obj $ codes [nameoftheneuron]获得的(som_obj是som()函数的返回值)
这里我写了从https://github.com/geoss/som_visualization_r
派生的基本函数 plotCluster <- function(som_obj, cutree.obj , col_palette){
if (som_obj$grid$topo != "hexagonal"){
stop("function assumes hexgonal SOM")
}
Hexagon <- function (x, y, unitcell = 1, col = "grey", border=NA) {
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=border)
}
plot(0, 0, type = "n", axes = FALSE, xlim=c(0, som_obj$grid$xdim),
ylim=c(0, som_obj$grid$ydim), xlab="", ylab= "", asp=1, main= "Clusters")
if(!is.null(col_palette)){
ColorCode = col_palette[cutree.obj]
}
else{
ColorCode <- as.factor(cutree.obj)
}
offset <- 0.5 #offset for the hexagons when moving up a row
ind <- 1
for (row in 1:som_obj$grid$ydim) {
for (column in 0:(som_obj$grid$xdim - 1)) {
Hexagon(column + offset, row - 1, col = ColorCode[ind])
ind <- ind +1}
offset <- ifelse(offset, 0, 0.5)
}
}
我只想知道如何在我自己的情节中添加瓷砖中的每个地块。 我知道如何执行该操作。我完全没有做到这一点的线索。 我试图从plot.kohonen获取绘图函数的代码,但我只从getAnywhere(plot.kohonen)获得截断的代码
这个问题似乎很复杂,但我只需要提示以下问题:
1 - 在下面的代码中想象的情节系统中,如何在每个图块中绘制某些内容(情节或文字)?