Can anyone suggest a solution? I was trying to convert it into the adjacency matrix and then make a heatmap from that. But that was giving me some weird adjacency matrix with many 0 values and hence a wrong heatmap as well. Since I am new to MATLAB, I would appreciate it if you have any ideas. Thank you.
How to convert the graph below in to heatmap?
5 views (last 30 days)
Show older comments
I have the graph below. It was plotted using the code below:
%% matrix (:,4) is the weight of the corresponding matrix(:1:2) branches. Ignore matrix(:,3).
nodes = [];
for i = 1:1:size(matrix,1)
if matrix(i,4) <= 10000
nodes = [nodes,matrix(i,1:2)];
end
end
nodes_cellarray{:} = nodes;
set(figure, 'Visible', 'on');
Graph = graph(matrix(:,1),matrix(:,2));
plot_array = plot(Graph, 'layout', 'auto');
% plot_array.EdgeColor = 'red';
highlight(plot_array,nodes_cellarray{:},'EdgeColor','r','NodeColor','r','LineWidth',4);
I have attached the matrix23.xlsx file that has the matrix 'matrix' used above.

2 Comments
Deepak Kumar
on 3 Jan 2020
Refer the below MATLAB documentation link to get more insight about "heatmap" function
Accepted Answer
Walter Roberson
on 3 Jan 2020
t = readtable('matrix23.xlsx');
mask = t{:,3} == 65535 | t{:,4} == 65535;
t(mask,:) = [];
figure(1)
h = heatmap(t, 'Var1', 'Var2', 'ColorVariable', 'Var3');
h.GridVisible = false;
figure(2)
subplot(1,3,1);
scatter(t{:,1}, t{:,2}, [], t{:,3});
title('scatter');
A = sparse(t{:,1}, t{:,2}, t{:,3}, 2600, 2600);
subplot(1,3,2)
spy(A);
title('normal spy');
subplot(1,3,3)
r = symrcm(A);
spy(A(r,r));
title('spy symrcm');
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!