Error using datatip() on surface. Method is not defined.
9 views (last 30 days)
Show older comments
Sanders A. on 10 Jun 2022
I am trying to add/move datatips on figures (3d surfaces) by giving the figure number and x and y positions and havaing the program figure out the correct z value and then generate the datatip. I've boiled down my issue to this scenario.
x = 0:0.1:4;
y = 4:0.2:8;
[X,Y] = meshgrid(x,y);
Z = sin(X+Y);
srf = surf(X,Y,Z);
xVal = 3.7;
yVal = 5;
[~,xIdx] = min(abs(xVal - srf.XData(1,:)));
[~,yIdx] = min(abs(yVal - srf.YData(:,1)));
dt = datatip(srf,xVal,yVal,srf.ZData(yIdx,xIdx)); %yes, it makes me put the x and y indices backwards...
This gives the error below:
"Warning: Error occurred while executing the listener callback for event MarkedClean defined for class matlab.graphics.datatip.DataTip:
Error using matlab.graphics.chart.primitive.Surface/getInterpolatedPointInDataUnits Method 'doGetInterpolatedPointInDataUnits' is not defined for class 'matlab.graphics.chart.primitive.Surface' or is removed from MATLAB's search path.
Error in matlab.graphics.datatip.DataTip
Error in matlab.graphics.datatip.DataTip>@(s,e)nDelayedMove()"
It also creates a dataip at the origin (x=0, y=4) with the corect z value.
I am encountering this on both versions '18.104.22.1681703 (R2020a) Update 7' and '22.214.171.1240957 (R2021a) Update 4', but not when I use the latest version through https://matlab.mathworks.com/ which has '126.96.36.1992586 (R2022a) Update 2'. There it just plots the wrong point the (x=3.2, y=4.2, z = 0.898708) until I rotate the view of the plot a bit from default and then run the last line (I'm still investigating what is the thing to do to get it to work but that seems beyond the scope of this. Solved?: Okay it seems to simulate a click on the correct spot which is behind a hump so it creates the datatip on the near face).
Do I just not have a package installed?
Find more on Surface and Mesh Plots 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!