According to the documentation, axis off
just sets the 'Visible'
property of the current axes to 'off'
. So you can turn off all axes of the current figure at once with
set(get(gcf, 'Children'), 'Visible', 'off')
However, the above code also removes the axis title, because somehow it also sets the 'Visible'
property of the title Text
objects to 'off'
. To avoid this, you can use the following, which removes the x-axes, the y-axes and the background color, without affecting the title:
t = get(get(gcf, 'Children'), 'XAxis');
set([t{:}], 'Visible', 'off')
t = get(get(gcf, 'Children'), 'YAxis');
set([t{:}], 'Visible', 'off')
set(get(gcf, 'Children'), 'Color', 'none')
Or you could do as in the first approach and then restore the titles:
set(get(gcf, 'Children'), 'Visible', 'off')
t = get(get(gcf, 'Children'), 'Title');
set([t{:}], 'Visible', 'on')