Reset Datatip to Standard
3 views (last 30 days)
Show older comments
Hey,
I am using a GUI with several axes. In some axes I plot 3D data, whereas in others I am boxplotting. For the 3D Data I created a customdatatip that now also applies to the boxplots. However, for the boxplots I want to use the standard datatip, which looks pretty fine for boxplots.
This is how I call the update function:
datacursormode on;
dcm = datacursormode;
set(dcm,'UpdateFcn',@customdatatip);
And this is how I programmed the function 'customdatatip':
function output_txt = customdatatip(obj,event_obj,str1, str2)
% Get Data
x_axis1 = getappdata(0, 'x_axis1');
x_axis1 = x_axis1{1}; % Read string
y_axis1 = getappdata(0, 'y_axis1');
y_axis1 = y_axis1{1}; % Read string
pos = get(event_obj, 'Position');
output_txt = {...
[x_axis3 ': ', num2str(pos(1),4)]...
[y_axis3 ': ', num2str(pos(2),4)] ...
[z_axis1 ': ', num2str(pos(3),4)] ...
['Legend: ', event_obj.Target.DisplayName]};
When I use the datatip, it gets me the output: Unable to update. Which is undersandable as I do not have such data for this boxplot. So, can I revert the Update function for the boxplots? Or limit the Update function just to the 3D plots? Or artificially recreate a boxplot datatip function?
Your support is very much appreciated!
Best, Mathias
0 Comments
Answers (1)
Carl
on 25 Aug 2017
Hi Mathias. A possible solution is to customize your customdatatip function to behave differently depending on which axes the callback occurs in. For example, see the code below:
% ah1 = handle to axes 1, ah2 = handle to axes 2
current_axes = event_obj.Target.Parent;
if current_axes == ah1
% datatip for first axes
elseif current_axes == ah2
% datatip for second axes
end
1 Comment
See Also
Categories
Find more on Legend 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!