|
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); |
3 | 6 | pos = event_obj.Position; |
4 | 7 | [~, idx] = min( (x - pos(1)).^2 + (y - pos(2)).^2 ); |
5 | 8 |
|
6 | 9 | 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 | + }; |
13 | 16 | else |
14 | 17 | output_txt = { |
15 | 18 | ['X: ', num2str(pos(1))], ... |
16 | 19 | ['Y: ', num2str(pos(2))], ... |
17 | 20 | ['Value: ', num2str(datatip(idx))] |
18 | | - }; |
| 21 | + }; |
19 | 22 | end |
20 | | - |
21 | 23 | end |
0 commit comments