How to number vertices in a delaunay triangulation in a plot

5 ビュー (過去 30 日間)
aasha verghese
aasha verghese 2022 年 6 月 16 日
コメント済み: aasha verghese 2022 年 6 月 17 日
Hi,
How to display numbers or ids of vertices in Delaunay triangulation plot. I am able to draw a circle for the nodes.
triplot(newDT,'-ob');
But how to show the specific vertex numbers in the plot?
Thanks

採用された回答

Steven Lord
Steven Lord 2022 年 6 月 16 日
Let's make a sample delaunayTriangulation and plot it.
x = rand(20,1);
y = rand(20,1);
dt = delaunayTriangulation(x,y);
triplot(dt);
Create an array of labels for the points. I'm just using the indices of each point, but if your points have some meaning (cities, for example) you could build your vector of labels taking advantage of that information.
labels = string(1:numel(x))
labels = 1×20 string array
"1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20"
Add the labels to the plot. If you wanted to be fancier you could add a slight offset to the x and/or y coordinates so the text appears a little bit further away from the point to which they correspond.
text(x, y, labels)
Let's spot check. Does the code below circle point 15?
hold on
plot(x(15), y(15), 'ro', 'MarkerSize', 20)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDelaunay Triangulation についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by