Pregunta

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

¿Fue útil?

Solución

>> 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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top