# Plotting two networks in the same layer using "graph"

11 visualizzazioni (ultimi 30 giorni)
NeGM il 20 Mar 2021
Commentato: NeGM il 25 Mar 2021
Hi Everyone,
I'd like to plot the following set of networks in which Network 1 and 2 are represented by blue and red connections respectively. Each network has it's own Adjecency matrix (A1 and A2). Ive tried using the following code. However, this seems to plot the networks separately(looks like it's double-layered) and not interconnected. I'd like to have a single layer with the edges being color coded as shown in the image below. Any help is greatly appreciated. Thank you in advance
G1 = graph(A1)
G2 = graph(A2)
figure(1)
plot(G1)
hold on
plot(G2)
hold off
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Shubham Rawat il 23 Mar 2021
Hi Nelson,
You may do like this:
%creating first graph
s = [1 1 2 3 3 3 4 4 5 6 7 7 8];
t = [2 3 6 4 6 8 5 8 9 7 8 9 9];
G = graph(s,t);
%plotting
h = plot(G);
%creating second graph
s1 = [3 3 6 7 7];
t1 = [6 8 7 8 9];
G1 = graph(s1,t1);
%highlighting second graph with red color edges and linewith 1.5
highlight(h,G1,'EdgeColor','r','LineWidth',1.5);
You may look at this documentation for further
Hope this Helps!
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
NeGM il 25 Mar 2021
Awesome, Thank you!

Accedi per commentare.

### Categorie

Scopri di più su Networks in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by