Numbered Patches
7 views (last 30 days)
Show older comments
Hello all,
The matlab documentation for patch shows an example where the patch faces and vertices are numbered.
Is it possible to automatically generate a numbered plot like this or is numbering only possible by annotating?
Thanks cjm2176
0 Comments
Answers (1)
Matt Fig
on 26 May 2011
It could be automated, something like:
xdata = [2 2 0 2 5;
2 8 2 4 5;
8 8 2 4 8];
ydata = [4 4 4 2 0;
8 4 6 2 2;
4 0 4 0 0];
zdata = zeros(3,5);
patch(xdata,ydata,zdata,'w')
mnx = sum(xdata)./size(xdata,1); % Or MEAN...
mny = sum(ydata)./size(ydata,1);
for ii = 1:numel(mnx)
T(ii) = text(mnx(ii),mny(ii),num2str(ii));
end
set(T,'color','b','fonts',12,'fontweight','bold')
The code after the patch creation could be put into a function M-file which takes the patch object's handle as an arg. Then from there extracts the vertices and does it's job. Of course it should go without saying that this approach will not work for certain patch shapes...
1 Comment
Walter Roberson
on 26 May 2011
And to answer the original question more explicitly: there is no (documented) Mathworks supplied routine or plotting option that does this on your behalf.
See Also
Categories
Find more on Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!