1
votes

Using the graph function in Adjacency Matrix Graph Construction, I am trying to plot a single undirected graph for two correlation matrices with edges identified by 1 and otherwise 0.

Both matrices share the same nodes but different edges. I am struggling to plot them in the same graph so that they share the same coordinate system and a clear comparison can be made straight from the graph. The two matrix graphs can be seen below:

enter image description here

Ideally, I would like them to be plotted on the same graph with the same node coordinate system with two different colours, one for each matrix.

1

1 Answers

0
votes

If I understood your question correctly, the code below should do what you asked:

g1 = graph(ones(3, 3));
g2 = graph([0 1 1; 1 0 1; 1 1 0]);

f1 = figure;
hold on;
h1 = plot(g1, 'Layout', 'layered');
h2 = plot(g2, 'Layout', 'layered');

h2.XData = h1.XData;
h2.YData = h1.YData;

h2.NodeLabel={};