Reset Datatip to Standard

조회 수: 5 (최근 30일)
Mathias Dirksmeier
Mathias Dirksmeier 2017년 8월 22일
댓글: Thomas Atta-Fosu 2017년 11월 30일
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
  댓글 수: 1
Thomas Atta-Fosu
Thomas Atta-Fosu 2017년 11월 30일
Thanks! I had a similar issue and this saved me!

댓글을 달려면 로그인하십시오.

카테고리

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