绘制两个子图

时间:2017-06-29 20:47:45

标签: matlab plot graph

我有一个图G,其中包含一组存储在nodeNames中的节点,我有两个G的子图A和B,如下所示:它只是一个较长代码的分区

    G = digraph(adj,nodeNames);
    h = plot(G);
    v = dfsearch(G,'n');
    disp(v);                             % v is a cell array that contains all the nodes are included in the path of n 
    A=subgraph(G,v);           % the first subgraph that contains the nodes that are included in the path of n 
    NoNodeAccess=setdiff(nodeNames,v);   % NoNodeAccess is a cell array that includes all the remaining nodes that are not in the path of n
    B=subgraph(G,NoNodeAccess);  % the second subgraph.

现在我想要一个包含两个子图的图,我想用线型区分它们,或者如果可能的话,只用每个子图圈。怎么做 ?谢谢

1 个答案:

答案 0 :(得分:0)

这个命令有助于在保持旧情节时生成新情节:

hold on

您可以在生成两个数字之间添加此命令。基本上新的情节将有不同的颜色与前一个颜色区分开来,你绝对可以使用plot属性来改变线条类型和颜色。

https://www.mathworks.com/help/matlab/ref/plot.html