How can I change e.g. the x-ticks from 1...10 to 2...20 without changing the plot?

I'm plotting frequencies. The Problem is that the first frequency in the matrix doesn't start at zero but at e.g. 200. So the scales start at zero what leads to a misunderstanding...

有帮助吗?

解决方案

>> surf(peaks)
>> ticklabels = get(gca,'XTickLabel');
>> newTicklabels = [ticklabels(2:end,:);'60'];
>> set(gca,'XTickLabel',newTicklabels);

Note that ticklabels are returned by the second line (above) is a 2 column char matrix. It can also be specified as a cell array of char (strings) which is often more convenient.

>> set(gca,'XTickLabel',{'1','14','341','123412','1432','1'}); % "random" labels
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top