How to number vertices in a delaunay triangulation in a plot

조회 수: 3 (최근 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 CenterFile Exchange에서 Delaunay Triangulation에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by