Question

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...

Was it helpful?

Solution

>> 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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top