Search code examples
matlabmatlab-figureaxesmultiple-axes

How to remove xticks and yticks from all axes?


I have three axes in figure and I want to remove xtick and ytick from all of them. I wrote below code but it works just on current axes, not all of them:

set(gca,'xtick',[],'ytick',[]);

How to remove xticks and yticks from all axes?


Solution

  • As a more general solution inspired by @Luis Mendo's answer, use findobj to get the axes. This will avoid getting all children of the parent figure which could include "non-axes" elements:

    set( findobj( gcf, 'Type', 'axes' ), 'XTick', [], 'YTick', [] );