Reset Datatip to Standard

4 次查看(过去 30 天)
Mathias Dirksmeier
Mathias Dirksmeier 2017-8-22
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

回答(1 个)

Carl
Carl 2017-8-25
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

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by