You can use the xticks
function (or the statement set(gca, 'xtick', ...)
) to choose which ones you want to display. Doing so will also affect the tick labels, because each tick has an associated label:
plot(1:8)
xticks([1 2 3 5 6 8]) % remove ticks and labels at 4 and 7
If you want to remove all ticks from the axis but keep (some or all) labels, you can set the tick length to 0
, which doesn't affect the labels:
plot(1:8)
xticks([1 2 3 5 6 8]) % remove ticks and labels at 4 and 7
set(get(gca, 'XAxis'), 'TickLength', [0 0]) % make all ticks have size 0