UIAxes toolbar for zooming disappears

16 次查看(过去 30 天)
I have a very simple app that includes a plot with UIAxes. When I start the app the toolbar for zooming, etc. is visible as normal.
However, after plotting it disappears, even though its properties is not changed and is supposedly still visible
K>> app.UILoadedDataPlot.Toolbar
ans =
AxesToolbar with properties:
Visible: on
SelectionChangedFcn: ''
I tried forcing it to visible changing the Visible property to "on", but it doesn't seem to work. Any ideas of why it disappears? FYI, this is my plotting code
plot(app.UILoadedDataPlot, t,x,"DisplayName",ThisEntry.ID);
hold(app.UILoadedDataPlot,"on");
legend(app.UILoadedDataPlot,"Location","best");

采纳的回答

Ayush
Ayush 2024-10-21,6:06
I was unable to reproduce this issue in MATLAB R2024a, indicating that it appears to be resolved in this release. To address the issue, I recommend upgrading your MATLAB version to R2024a.
Alternatively, if upgrading is not feasible, a potential workaround involves instructing the "UIAxes" to add an additional toolbar to the plot whenever new data is added.
For more detailed information, please refer to the following similar answer: https://www.mathworks.com/matlabcentral/answers/1712265
Hope it helps!

更多回答(1 个)

Umar
Umar 2024-10-16

Hi @Vittorio ,

After reviewing the documentation provided at the link below

https://www.mathworks.com/help/matlab/ref/matlab.ui.control.uiaxes-properties.html

I would suggest the following

Check Toolbar Properties: Even though you indicated that app.UILoadedDataPlot.Toolbar.Visible is set to on, it is crucial to confirm that this property remains unchanged after the plot command. It may be beneficial to explicitly set it again immediately after your plotting code:

   plot(app.UILoadedDataPlot, t, x, "DisplayName", ThisEntry.ID);
   hold(app.UILoadedDataPlot, "on");
   legend(app.UILoadedDataPlot, "Location", "best");
   app.UILoadedDataPlot.Toolbar.Visible = 'on';  % Reaffirm visibility

Rendering Issues: Sometimes UI components might not render correctly due to overlapping objects or layout issues. Make sure that your UIAxes is not being obscured by other UI components like buttons or panels. Adjusting the z-order of these components can help:

    uistack(app.UILoadedDataPlot, 'top');  % Bring UIAxes to front

Parent Container Settings: If the UIAxes is contained within a panel or another container, check if that parent container has properties that may affect visibility (like Clipping or Visible). Ensure both are set correctly:

   app.ParentContainer.Clipping = 'off';  % Example: disable clipping

Recreate Toolbar: If the toolbar continues to malfunction, consider recreating it using the axtoolbar function after your plotting commands:

   axToolbar = axtoolbar(app.UILoadedDataPlot);
   axToolbar.addTool('Zoom', 'zoom');
   axToolbar.addTool('Pan', 'pan');

Make sure you are using a compatible version of MATLAB for your app design, as some properties and behaviors have changed across versions. If possible, check for updates or patches that might address UI component issues.

Try creating a minimal version of your app with just the plotting functionality to isolate and test whether the issue persists without additional complexity. Also,consider implementing error handling or notifications within your app to inform users if certain functionalities are unavailable, enhancing user experience.

Hopefully following these suggestions and going through documentation provided in the link will help resolve your issues.

  3 个评论
Umar
Umar 2024-10-17

Hi @Vittorio,

I did some research on mathworks.com and found this form. Please click it and let me know if this helps resolve your problem.

https://www.mathworks.com/matlabcentral/answers/1712265-toolbar-of-plot-hiding-after-loading-file?s_tid=answers_rc1-2_p2_MLT

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by