Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable axis in all subplots within one figure?

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?

like image 529
Derdesdoof Avatar asked Nov 19 '25 20:11

Derdesdoof


1 Answers

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')
like image 168
Luis Mendo Avatar answered Nov 24 '25 23:11

Luis Mendo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!