Trisurf(f,x,y,z) function can draw a patch object. How can I add datatip to this object at the known vertices index with code?
I tried to use the following codes in 2017b
cursorMode = datacursormode(gcf);
hdtip = cursorMode.createDatatip(h_surf); %h_surf is the handle of trisurf
hdtip.Cursor.Position=pos; %this commond seems cannot find the exact vertex and depends on the view angle, where pos is the vertex coordinates.
hdtip.Cursor.DataIndex=idx; %try to use this command to assign the vertex index, but not successful.DataIndex seems not the vertex index.
CodePudding user response:
Accordint to @Woffie's suggestions, I tuned a little bit to reproduce the error with different view angle in 2017b and 2019b.
First to enable view([180,0]);
line. Run the code to get the correct result. And then to comment this line, only remain view([0,0]);
to get the wrong result. But if add 'Close all' in the front of the script, should get the correct result each time.
It might be good to note, in 2D plots, this usually is not a problem since one doesn't usually change the view.
ngrid=1000;