1

I'm currently working on SOM vizualisations.

This is a SOM map with codes plots generated by using kohonen package Shortly, each circle is a neuron and inside each neuron we plot all the variable in a spectra shape. This plot is obtain by som_obj$codes[nameoftheneuron] (som_obj is the return value of som() function) kohonen plot

here i have written basic function derived from 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)
  }
}

hexagonal plot

I only want to know how to add each plot in the tiles on my own plot. I have 0 idea how to perform that. I have literally no clue for doing that. I tried to get the code of the plot function from plot.kohonen but I get the truncated code only from getAnywhere(plot.kohonen)

This problem seems to be complex but I just need hints with the following question:

1 - In the plot systems imagined in the code below, how to plot something (plot or text) in each tiles?

Olorin.G
  • 37
  • 7

0 Answers0