ggsom

Set of different visualizations for the kohonen SOMs (Self-Organising Maps) package using ggplot.

Example of line plot with color

library(ggsom)
suppressMessages(library(tidyverse))
suppressMessages(library(kohonen))
library(ggthemes)

iris_som <-
kohonen::som(scale(iris[1:4]), grid = somgrid(6, 4, "rectangular"))
ggsom::ggsom_line(aes_som(iris_som), TRUE)

plot of chunk unnamed-chunk-1

Example of line plot without color

library(ggsom)
suppressMessages(library(tidyverse))
suppressMessages(library(kohonen))
library(ggthemes)

iris_som <-
kohonen::som(scale(iris[1:4]), grid = somgrid(6, 4, "rectangular"))
ggsom::ggsom_line(aes_som(iris_som), FALSE)

plot of chunk unnamed-chunk-2

Example of ribbon plot

library(ggsom)
suppressMessages(library(tidyverse))
suppressMessages(library(kohonen))
library(ggthemes)

iris_som <-
kohonen::som(scale(iris[1:4]), grid = somgrid(6, 4, "rectangular"))
ggsom_ribbon(aes_som(iris_som, cutree_value = 2) , TRUE)

plot of chunk unnamed-chunk-3

Example of rect plot

library(ggsom)
suppressMessages(library(tidyverse))
suppressMessages(library(kohonen))
library(ggthemes)

iris_som <-
kohonen::som(scale(iris[1:4]), grid = somgrid(6, 4, "rectangular"))
ggsom_rect(aes_som(iris_som, cutree_value = 4), TRUE)

plot of chunk unnamed-chunk-4