How to change the x ticket lables in a plot?

조회 수: 3 (최근 30일)
Andrea
Andrea 2012년 11월 6일
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
Matt Fig
Matt Fig 2012년 11월 6일
It is not clear what you intend. Where exactly do you want the ticklabels? At [1 3 5 7 9 11] or what?

댓글을 달려면 로그인하십시오.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 6일
편집: Azzi Abdelmalek 2012년 11월 6일
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

추가 답변 (1개)

Kye Taylor
Kye Taylor 2012년 11월 6일
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)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by