MATLAB: How to make an axes component visible/invisible in AppDesigner (switching between Axes)

axesbackgrounddarkgreyinvisibleMATLABpanelswitchuiuiaxesuifigureuipanelvisible

When using the 'Visible' property of an UIAxes object, there is a grey rectangle after setting 'visible' property to 'off'.
How to make an Axes component visible/invisible in AppDesigner (switching between Axes)?

Best Answer

Switching the 'visible' property from a UIAxes from 'on' to 'off' only changes the visiblity of the content of the Axes, but it is not deleting the whole object.
It is also not possible to make the background color transparent.
An easy workaround would be to set the position of the Axes to a region which is a region which is not in the window of the designed App.
This also includes that you have to reset the position for bringing the Axes back to "visiblity".
The maybe "best" way to accomplish this would be to use containers.
For each Axes you need one Panel. Drag the Axes into the Panel Container.
After that you can switch the visibility of the Axes with the 'visible' property of the Panel Container.
Here you can see how this would look like (The panels do not overlap completely only for the purpose to see that there is another panel in the background):
The code for switching the visibility to 'on' from 'Panel' would be the following:
app.Panel.Visible = 'on';
For switching it to 'off' please use the following:
app.Panel.Visible = 'off';
Here you can find more information about Panels in the documentation:
Here you can find more information about uiaxes in the documentation: