Reset Datatip to Standard

5 visualizaciones (últimos 30 días)
Mathias Dirksmeier
Mathias Dirksmeier el 22 de Ag. de 2017
Comentada: Thomas Atta-Fosu el 30 de Nov. de 2017
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

Respuestas (1)

Carl
Carl el 25 de Ag. de 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 comentario
Thomas Atta-Fosu
Thomas Atta-Fosu el 30 de Nov. de 2017
Thanks! I had a similar issue and this saved me!

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by