Change Node & Edges position on Plot

29 ビュー (過去 30 日間)
Mohamed
Mohamed 2022 年 6 月 26 日
コメント済み: Christine Tobler 2022 年 8 月 2 日
I'm trying to draw a network using Graph function, where nodes represent RMU and Edges represent Cable , but i wanna change the postion of multibale Nodes on the plot figure so that is can see the network and compare it to the original SLDs

採用された回答

Steven Lord
Steven Lord 2022 年 6 月 26 日
See the "Adjust Properties of GraphPlot Object" example on this documentation page for a demonstration of how to set custom node locations. Alternately you may want to use the layout function linked in the Object Functions section on that page to use different algorithms to compute the coordinates for the points.
  2 件のコメント
Mohamed
Mohamed 2022 年 8 月 2 日
編集済み: Mohamed 2022 年 8 月 2 日
I tried to the following function to manpuilate xData nd Ydate for the garph , i used a point and get the coordinated of the pointer , but i can't assign the point corrdinates to the Xdate and Ydate of the selected Node :
Nodes=G.Nodes
H=plot(G,'Layout','force','NodeLabel',G.Nodes.Name)
guidata(H,data)
H.ButtonDownFcn = @MoveNode;
function MoveNode(src,evnt,Nodes) %#ok<INUSL>
H = guidata(gcbf);
set(gcf,'pointer','fleur','WindowButtonMotionFcn',{@Move});
set(gcf,'WindowButtonDownFcn','set(gcf,''WindowButtonMotionFcn'',[],''pointer'',''arrow'')');
guidata(gcbf,H);
function Move(src,evnt,Nodes) %#ok<INUSL>
P = get(gca,'CurrentPoint')
x = round(P(1,1));
y = round(P(1,2));
end
end
i used that toolBox and the source code as a reference to me :
https://www.mathworks.com/matlabcentral/fileexchange/57612-da-gui
Christine Tobler
Christine Tobler 2022 年 8 月 2 日
You should be able to assing to the XData and YData properties of the H object in your code:
g = graph(2, 3);
H = plot(g, 'Layout', 'force');
H.XData = [1 3 2];
In the helper functions you're using, you would need to retrieve the GraphPlot object represented by H and modify its properties XData and YData.
Also, here's a blog post on how to make nodes in a GraphPlot object move by clicking on them:

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by