UIAxes toolbar very slow just to turn off

31 views (last 30 days)
Adam
Adam on 30 Sep 2025 at 14:13
Edited: Adam on 7 Oct 2025 at 16:43
I'm trying to create a uifigure containing a component (panel containing gridlayouts, axes, etc) that was built in AppDesigner. I turn off the uiaxes toolbar for my axes (three of them per panel, I have 3 panels) because I don't want it on any of them. But when I ran the profiler to see why it takes so long for my figure to launch this is what I see.
Why is it taking so long just to make a toolbar invisible? Is there a faster way to do this? Obviously it would be better if it simply didn't create the toolbar, because when I dig deeper into the profiler I find that 'createToolbarButton' is where most of the time is being spent, even though I'm turning the toolbar off in every one of my axes.
I can't use regular axes, because it's in an AppDesigner component, though I don't know if they are faster anyway.

Accepted Answer

Benjamin Kraus
Benjamin Kraus on 2 Oct 2025 at 13:54
There are two ways to "remove" the Axes Toolbar:
  1. You can set the Visibility off. Setting the Visibility of the axes toolbar requires you to create the toolbar before you can set the visibility (you can't set a property on an object that does not exist).
  2. You can set the Toolbar property on the axes to [] to completely remove the toolbar. If you set the Toolbar property to empty before the toolbar is created, then you can avoid the time required to create the toolbar.
Unfortunately, the App Designer user interface does not provide an easy way to do the second option, but it is still possible to do in App Designer using the startupFcn.
  1. Leave the "Toolbar.Visible" checkbox checked in the App Designer Component Browser's Property Inspector. If you uncheck this checkbox it will insert the code you showed above, which will force the creation of the toolbar in order to set the Visible property.
  2. Instead, add a new app startupFcn callback.
  3. Insert the code below into the startupFcn. As long as this runs before the first time a graphics update is called, you can avoid the time required to create the toolbar.
function startupFcn(app)
app.UIAxes.Toolbar = [];
end
We have been working to improve the time required for the axes toolbar creation in recent releases. I tested the steps above in R2025a, but your results may vary in older releases. I'll also talk to my colleagues on the App Designer team to make this workflow easier to do.
  1 Comment
Adam
Adam on 7 Oct 2025 at 16:41
Edited: Adam on 7 Oct 2025 at 16:43
Thanks. This does seem to work faster. First time I ran it, the first axes took a significant amount of time to create, while the second was fast, then next time I ran it both were created quite quickly so I guess that was just some function caching/first time call behaviour, but the setting toolbars to [] line takes next to no time at all, so this is indeed much better.
In case it's useful to anyone else, in my case I put the code in the postSetupFcn, as I am working in a component, and this is the equivalent place to the startupFcn in an app.

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!