Generating a heat map of adjacency matrix

10 visualizaciones (últimos 30 días)
Joseph Turner
Joseph Turner el 10 de Abr. de 2021
Editada: dpb el 12 de Abr. de 2021
I am trying to generate a heat map of an adjacency matrix from a particular graph with only two colours (a 100 x 100 array of squares).
I have the following code so far, with G1 being my function:
B=adjacency(G1);
adj=full(B);
heatmap(B)
Any help would be appreciated

Respuesta aceptada

dpb
dpb el 11 de Abr. de 2021
Editada: dpb el 12 de Abr. de 2021
Presuming you want the displayed values of the cells to still be their totals, then
s = [1 1 1 2 2 3];
t = [2 3 4 5 6 7];
G = digraph(s,t);
A = adjacency(G);
hHM=heatmap(B);
hHM.Colormap=[ones(1,3);zeros(max(hHM.ColorData(:)),3)];
will set the colormap to two-tone of black-white for zero-nonzero values. You can change the hue by modifiying the RGB ratio of the ones() array to suit.
The color data are what are in the data cells and scaled against the colormap -- you get the same colors by
hHM=heatmap(double(B>0));
but the cell values displayed will only be 0|1. You have to change the colormap scaling to map the colors by faking interpolation such that the breakpoint is between zero and the minumn number of connections.

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by