R package Kohonen - how to plot hexagons instead of circles as in Matlab SOM toolbox?

后端 未结 3 722
眼角桃花
眼角桃花 2021-01-01 03:00

Is it possible to plot the SOM map (package Kohonen) with hexagons as elementary forms instead of circles? Now the different plottings (count, changes etc.) are plotted as

3条回答
  •  失恋的感觉
    2021-01-01 03:31

    You can use Voronoi plots to get a space filled representation (hexagons).

    • the hex grid coordinates are stored in $grid$pts of the kohonen object,
    • the codes are in $codes

    Putting this together with a lattice plot:

    require ("kohonen")
    require ("latticeExtra")
    require ("deldir")
    som.wines <- som (scale (wines), grid = somgrid(5, 5, "hexagonal"))
    
    df <- as.data.frame (cbind (som.wines$grid$pts, som.wines$codes))
    levelplot (alcohol ~ x * y, data = df, panel = panel.voronoi, aspect = "iso)
    

    yields:

    kononen map hex plot

    (I don't know for sure, but I guess that would have been possible already in 2010).

提交回复
热议问题