How to number vertices in a delaunay triangulation in a plot
조회 수: 3 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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))
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 Exchange에서 Delaunay Triangulation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!