Why does setting the "Visible" property for axes to "Off" also set the "Visible" property for title and axis labels, which are its children?

64 views (last 30 days)
I expected the axes "Visible" property to work as documented in the MATLAB Function Reference (Graphics Section). According to the documentation,
The Visible property of an axes object does not affect the children of axes.
But if I create a new axes, and add title and/or axis labels to it, and turn off the "Visible" option, then title and axis labels, which are children of the axes, also become invisible.
The documentation for the "Visible" property of axes is available here:
or you can execute the following command at the MATLAb command prompt:
web([docroot '/techdoc/ref/axes_props.html#Visible'])

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Jul 2020
The documentation on axes properties ("Visible" and "Children") is incorrect regarding the inheritance of parent object properties for the associated child objects, like TITLE and XLABEL.
As a workaround, to ensure that title and axis labels do not become invisible on making the axes invisible, you can use something like,
axes
title(axes title)
xlabel(X-axis label)
set(gca, 'visible', 'off')
set(findall(gca, 'type', 'text'), 'visible', 'on')

More Answers (0)

Tags

No tags entered yet.

Products

Community Treasure Hunt

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

Start Hunting!