Can additional information be added to the directed graph plotting node 'tooltip'?
4 ビュー (過去 30 日間)
古いコメントを表示
Michael Mazack
2023 年 8 月 30 日
コメント済み: Christine Tobler
2023 年 8 月 30 日
Hello.
I'm working with visualizing directed graphs in MATLAB and am trying to determine if there is a way to add additional graph metadata to the 'tooltip' that appears when hovering over a node. The code and screenshot below may help explain my question a bit more.
nodeNames = {'Node A', 'Node B', 'Node C', 'Node D', 'Node E', 'Node F'};
edges = [[1 3]; [2 3]; [3 4]; [4 6]; [5 6]];
G = digraph(edges(:,1), edges(:,2), [], nodeNames);
plot(G)
What I want to do is add additional information where it says "In Degree 2" & "Out Degree 1".
For example, could I add another line that says " Metadata Value 4.53" and do this in a way that the value is variable with each node?
If there's not a way to do this on the tooltip, is it possible to do it some other way besides ad-hoc changing the node names to include the information?
0 件のコメント
採用された回答
Christine Tobler
2023 年 8 月 30 日
nodeNames = {'Node A', 'Node B', 'Node C', 'Node D', 'Node E', 'Node F'};
edges = [[1 3]; [2 3]; [3 4]; [4 6]; [5 6]];
G = digraph(edges(:,1), edges(:,2), [], nodeNames);
p = plot(G);
newrow = dataTipTextRow('Metadata Value', rand(numnodes(G), 1)); % Provide one value per node
p.DataTipTemplate.DataTipRows(end+1) = newrow;
datatip(p);
3 件のコメント
Joe
2023 年 8 月 30 日
Sorry if this is better done as a new thread, but it is relevant to the tool tip. And yes, this is excellent! In this simple graph, in/out degree are pretty obvious. Can the tool tip be configured to remove that information?
Christine Tobler
2023 年 8 月 30 日
Yes, you can use
p.DataTipTemplate.DataTipRows([2 3]) = [];
to delete those rows. You could also modify those rows by changing their Label and Value properties.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graph and Network Algorithms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!