Clear Filters
Clear Filters

difference between axe toolbar in app designer and in standalone application

2 views (last 30 days)
Hello,
In app designer (R2020b), the default axe toolbar menu is composed of 'export', 'brush','zoomin','zoomout',and 'restoreview' buttons. 'datacursor' is not present but when no button are selected, the datacursor is automatically active and works correctly.
When I export this app as standalone application, only 'export', 'zoomin','zoomout',and 'restoreview' are now available and datacursor function is not active.
Is there a solution to fix this problem?
Thanks for your help.
Philippe

Answers (2)

Nivedita
Nivedita on 14 Sep 2023
Edited: Nivedita on 14 Sep 2023
Hi Philippe,
I understand that you are unable to get the "datacursor" function in the standalone application.
To fix this issue, you can create custom datatips for your plot. Here is an example how you can do so:
methods (Access = private)
function output_txt = myUpdateFcn(app,info)
% Get the datatip position
y = info.Position(2);
x = info.Position(1);
% Create the datatip text
output_txt = {sprintf('X: %.3f', x), sprintf('Y: %.3f', y)};
end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
x = [0 1 2 3 4 5 6 7 8 9];
y = [0 1 2 3 4 5 6 7 8 9];
plot(app.UIAxes, x, y);
dcm = datacursormode(app.UIFigure);
dcm.Enable = 'on';
dcm.DisplayStyle = 'datatip';
dcm.UpdateFcn = @(src, event)myUpdateFcn(app, event);
end
end
  • In the “startup” function, a line plot is generated using random data. Then the “datacursormode” object (“dcm”) is enabled and set to display datatips. The “UpdateFcn” property is set to the “myUpdateFcn” function, which will be called when the datatip is updated.
  • Inside “myUpdateFcn,the x and y coordinates are extracted from the info.Positionproperty. The datatiptext is created using “sprint”to format the x and y coordinates with three decimal places.
For more information about “datacursormode”, you can refer to the following documentation link:
I hope this helps!
Regards,
Nivedita.

Philippe DI BIN
Philippe DI BIN on 14 Sep 2023
Hello Nivedita,
Thank you for your answer and your solution. I'll try it as soon as possible.
SIncerely.
Philippe

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!