Moving MATLAB axis ticks by a half step
问题 I'm trying to position MATLAB's ticks to line up with my grid, but I can't find a good way to offset the labels. Also, if I run set(gca,'XTickLabel',1:10) , my x tick labels end up ranging from 1 to 5. What gives? 回答1: You need to move the ticks, but get the labels before and write them back after moving: f = figure(1) X = randi(10,10,10); surf(X) view(0,90) ax = gca; XTick = get(ax, 'XTick') XTickLabel = get(ax, 'XTickLabel') set(ax,'XTick',XTick+0.5) set(ax,'XTickLabel',XTickLabel) YTick =