Skip to content

Commit debc152

Browse files
authored
Update plot_datatip.m
1 parent 2cc88af commit debc152

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/m/plot/plot_datatip.m

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
function output_txt = plot_datatip(~, event_obj, x, y, field, datatip)
2-
1+
function output_txt = plot_datatip(~, event_obj, datatip)
2+
p = event_obj.Target;
3+
field = p.FaceVertexCData;
4+
x = p.Vertices(:,1);
5+
y = p.Vertices(:,2);
36
pos = event_obj.Position;
47
[~, idx] = min( (x - pos(1)).^2 + (y - pos(2)).^2 );
58

69
if strcmp(datatip, 'vertex-field')
7-
output_txt = {
8-
['X: ', num2str(pos(1))], ...
9-
['Y: ', num2str(pos(2))], ...
10-
['Vertex #: ', num2str(idx)], ...
11-
['Field: ', num2str(field(idx))]
12-
};
10+
output_txt = {
11+
['X: ', num2str(pos(1))], ...
12+
['Y: ', num2str(pos(2))], ...
13+
['Vertex #: ', num2str(idx)], ...
14+
['Field: ', num2str(field(idx))]
15+
};
1316
else
1417
output_txt = {
1518
['X: ', num2str(pos(1))], ...
1619
['Y: ', num2str(pos(2))], ...
1720
['Value: ', num2str(datatip(idx))]
18-
};
21+
};
1922
end
20-
2123
end

0 commit comments

Comments
 (0)