提取Kohonen图的每个节点的HTML颜色代码

时间:2014-12-10 09:55:09

标签: r som

我使用以下脚本绘制SOM,我想提取与每个节点对应的HTML颜色代码。

它似乎不在som_model s3对象中。

有什么想法吗?

library(kohonen)

data<-matrix(c(-0.406,-0.406,-0.406,-0.406,2.463,-0.406,-0.406,2.463,-0.406,-0.406,-0.406,-0.406,
  -0.406,-0.406,-0.406,-0.406,-0.406,-0.406,-0.406,-0.406,0.4188448,1.6027146,0.7208751,
  0.7724322,0.5655424,-1.6969826,0.3429044,0.396769,0.3224141,-0.7324542,-0.5303228,0.9943725,
  -0.0324817,1.321637,-1.1985506,-0.3409802,-0.1393889,-0.3964047,0.9597519,-0.2443682), ncol=2)    

som_grid <- somgrid(xdim = 4, ydim=4, topo="hexagonal")

som_model <- som(data, 
                 grid=som_grid, 
                 rlen=100, 
                 alpha=c(0.05,0.01), 
                 keep.data = TRUE,
                 n.hood='circular')

plot(som_model,type="count")

我正在寻找的输出是一个列表/向量,每个节点都有颜色代码: &#34;#0000FF&#34;,&#34;#FF0000&#34; ...

1 个答案:

答案 0 :(得分:0)

plot来电实际上是对plot.kohonen的调用,并且反过来调用plot.kohprop来设置一些情节美学,包括配色方案。默认颜色方案为heat.colors + gray。对于您的情况,您可以执行heat.colors(3),然后查看som_model$grid以确定颜色映射。

只需在R控制台输入函数名称sans parens,即可看到plot.kohprop的作用。