my friend and I want to plot 32 subplots into one figure. All of them have to have their axes disabled. At the moment we iterate over all subplots, do their calculations and do
axis off
for each subplot. 33% of our overall time originates from that line. Is there a way to shut off axes for all subplots at once or another faster method?
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')