필터 지우기
필터 지우기

datacursormode isn't working on a specific UIAxes for Matlab R2023a

조회 수: 16 (최근 30일)
Omnia
Omnia 2023년 10월 23일
댓글: Walter Roberson 2024년 1월 27일
I have MATLAB R2023a. I have a matlab app with different UIAxes. I would like to assign different custom data cursor behavior for each UIAxes. However, when I try to use:
dcm1 = datacursormode(app.UIAxes1, 'on');
set(dcm1, 'UpdateFcn', @(~, event_obj) customDataCursorForUIAxes1(app, event_obj));
I get matlab error saying: Invalid figure handle. I don't understand what's the reason behind that specifically that it's supposed to be a valid new feature:
"datacursormode(ax,option) sets the data cursor mode for the specified axes. For example, to enable data cursor mode for the axes ax, use datacursormode(ax,'on'). Use this syntax with apps created in App Designer and using the uifigure function. (since R2023a)"
  댓글 수: 8
Wenzhao
Wenzhao 2024년 1월 27일
Exactly. I just give it as an example.
When I was developing an APP, it would be like this " datacursormode(app.UIaxes_xxx, 'on')". But it doesnt work.
That is why I check datacursormode.m file and HELP.
As I emphasized ("DATACURSORMODE only works on figure handle not on axe handle yet."), the datacursormode.m is not support what HELP tell.
Walter Roberson
Walter Roberson 2024년 1월 27일
The comments have not been updated to reflect accepting an axes. The code for handling an axes starts at roughly line 117
webAxesInputArgument = (nargin > 0) && matlab.graphics.interaction.internal.isWebAxes(varargin{1});

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

답변 (1개)

Walter Roberson
Walter Roberson 2023년 10월 25일
At the time you make the call
dcm1 = datacursormode(app.UIAxes1, 'on');
app.UIAxes1 is not a valid Axes object that is parented by a uifigure .
For example it might be parented by a traditional figure, or it might have been deleted.
(Or at least toolbox/matlab/graphics/+matlab/+graphics/+interaction/+internal/isWebAxes.p cannot detect that it is an Axes parented by a uifigure. That is a .p file so we cannot check it for potential bugs involving container objects.)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by