Effacer les filtres
Effacer les filtres

How to number vertices in a delaunay triangulation in a plot

5 vues (au cours des 30 derniers jours)
aasha verghese
aasha verghese le 16 Juin 2022
Commenté : aasha verghese le 17 Juin 2022
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

Réponse acceptée

Steven Lord
Steven Lord le 16 Juin 2022
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)

Plus de réponses (0)

Catégories

En savoir plus sur Delaunay Triangulation dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by