difference between axe toolbar in app designer and in standalone application

2 visualizaciones (últimos 30 días)
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.

Respuestas (2)

Nivedita el 14 de Sept. de 2023
Editada: Nivedita el 14 de Sept. de 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)};
% 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);
  • 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!

Philippe DI BIN
Philippe DI BIN el 14 de Sept. de 2023
Hello Nivedita,
Thank you for your answer and your solution. I'll try it as soon as possible.
  1 comentario
Nivedita el 14 de Sept. de 2023
Editada: Nivedita el 14 de Sept. de 2023
Hi Philippe,
Do accept the answer if it works out!

Iniciar sesión para comentar.


Más información sobre Environment and Settings en Help Center y File Exchange.




Community Treasure Hunt

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

Start Hunting!

Translated by