How to number vertices in a delaunay triangulation in a plot

8 次查看(过去 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

采纳的回答

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