Remove specific edgelabels in the plot of a graph

3 ビュー (過去 30 日間)
Gaetano Pavone
Gaetano Pavone 2021 年 3 月 14 日
コメント済み: Aghamarsh Varanasi 2021 年 3 月 17 日
I would like to remove specific edgelabels in the plot of a graph. In particular, edgelabels that do not satisfy some conditions.
For example, in my graph plot function I have:
edgename=(1:7)';
active=[1 2];
passive=[4 5];
labeledge(p,edgename(~active|~passive),'');
p is the plot.
However, it doesn't work.
How can I do this?

採用された回答

Aghamarsh Varanasi
Aghamarsh Varanasi 2021 年 3 月 17 日
Hi,
You can use a index array to specify which graph edges to have the edgeLabels. For example,
s = [1 1 1 2 2 3 4];
t = [2 3 4 2 5 6 7];
G = graph(s,t);
h = plot(G);
% edges that are not labled
active = [1,2];
passive = [4,5];
edgesNotLabled = [active passive];
% create index array
idx = 1:numedges(G);
idx(edgesNotLabled) = [];
edgename=(1:7)';
% label remaining edges in idx
labeledge(h, idx, edgename(idx));
  2 件のコメント
Gaetano Pavone
Gaetano Pavone 2021 年 3 月 17 日
Thank you, but I would like to remove all indexes that are not related to active and passive elements
Aghamarsh Varanasi
Aghamarsh Varanasi 2021 年 3 月 17 日
You could instead use 'edgesNotLabled' variable in the above code for labeling active and passive elements only.
labeledge(h, edgesNotLabled, edgename(edgesNotLabled));

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by