Clear Filters
Clear Filters

How can I color the external hexagon of each patch when I use "plotsomhits"?

2 views (last 30 days)
Hi! I would like to know how can I change the color of the external hexagon for each patch when I obtain the Hits using the function "plotsomhits".
I proceeded in this way but in this case only the internal hexagon is colored, not the external one.
plotsomhits(net,x)
patches = findobj(get(gca,'Children'),'Type','Patch');
set(patches(1:100),'FaceColor',[0 0.4470 0.7410]);
In the attachments the result in .jpg.

Answers (1)

Varun
Varun on 16 May 2023
I ran your code snippet for the “iris_dataset” taken from this example: https://www.mathworks.com/help/deeplearning/ref/plotsomhits.html#bt5s_mh and observed that the “patches” object contains double the number of neurons in the SOM. Here is the code snippet:
x = iris_dataset;
net = selforgmap([5 5]);
net = train(net,x);
plotsomhits(net,x)
patches = findobj(get(gca,'Children'),'Type','Patch');
set(patches(1:25),'FaceColor',[0 0.4470 0.7410]);
set(patches(26:50),'FaceColor',[1 0.4470 0.7410]);
Here, tThe dimensions passed to the “selforgmap” are [5 5] which mean, there are 25 neurons in the map. However, the variable “patches” is an array of 50 patch objects. So, in the “patches” array, the first 25 patch objects represent the internal hexagons, while the next 25 objects represent the external hexagons, which led me to the following result:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!