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

1 次查看(过去 30 天)
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.

回答(1 个)

Varun
Varun 2023-5-16
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:

类别

Help CenterFile Exchange 中查找有关 Polygons 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by