Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/m/plot/applyoptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@ function applyoptions(md,data,options)
set(gca,'pos',Axis);
end

if exist(options,'datatip'),
datatip = getfieldvalue(options, 'datatip');
dcm = datacursormode(gcf);
set(dcm, 'Enable', 'on');
set(dcm, 'UpdateFcn', {@plot_datatip, datatip});
end

%showregion
if strcmpi(getfieldvalue(options,'showregion','off'),'on'),
%Keep pointer of main axis
Expand Down
23 changes: 23 additions & 0 deletions src/m/plot/plot_datatip.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function output_txt = plot_datatip(~, event_obj, datatip)
p = event_obj.Target;
field = p.FaceVertexCData;
x = p.Vertices(:,1);
y = p.Vertices(:,2);
pos = event_obj.Position;
[~, idx] = min( (x - pos(1)).^2 + (y - pos(2)).^2 );

if strcmp(datatip, 'vertex-field')
output_txt = {
['X: ', num2str(pos(1))], ...
['Y: ', num2str(pos(2))], ...
['Vertex #: ', num2str(idx)], ...
['Field: ', num2str(field(idx))]
};
else
output_txt = {
['X: ', num2str(pos(1))], ...
['Y: ', num2str(pos(2))], ...
['Value: ', num2str(datatip(idx))]
};
end
end
1 change: 1 addition & 0 deletions src/m/plot/plotdoc.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function plotdoc()
disp(' ''contourticks'': ''on'' or ''off'' to display the ticks of the contours');
disp(' ''contouronly'': ''on'' or ''off'' to display the contours on a white background');
disp(' ''contourcolor'': ticks and contour color');
disp(' ''datatip'': an additional datatip entry (''vertex-field'' for vertex number and field value, or any md.mesh.numberofvertices length array');
disp(' ''density'': density of quivers (one arrow every N nodes, N integer)');
disp(' ''inset'': add an inset (zoom) of the current figure if 1 (use ''insetx'', ''insety'' and ''insetpos'' to determine the inset position and content)');
disp(' ''insetx'': [min(x) max(x)] where min(x) and max(x) are values determining the inset content');
Expand Down