How to change the x ticket lables in a plot?

3 Ansichten (letzte 30 Tage)
Andrea
Andrea am 6 Nov. 2012
Hi, I have : x=1:12 %the index of months
y=x.^2;
plot(x,y)
No I want to change the position of x labels from below the tickets to the middle of interval (between every 2 tickets). Can you please help me?
  1 Kommentar
Matt Fig
Matt Fig am 6 Nov. 2012
It is not clear what you intend. Where exactly do you want the ticklabels? At [1 3 5 7 9 11] or what?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 6 Nov. 2012
Bearbeitet: Azzi Abdelmalek am 6 Nov. 2012
x=1:12 %the index of months
y=x.^2;
plot(x,y)
set(gca,'xtick',[ 1 3 5 7 9 11]) % use whatever you want

Weitere Antworten (1)

Kye Taylor
Kye Taylor am 6 Nov. 2012
Try
x = 1:12;
y = x.^2;
plot(x,y);
tickLocations = [3,6,9]; % change to whatever you want
tickLabels = {'3','6','9'}; % change to whatever you want
set(gca,'xTick',tickLocations,'xTickLabel',tickLabels)

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by