I made a line plot of a 30x1 matrix. Of course the values on the x-axis are 1-30 but I need to add 1970 to each of those because the axis is supposed to represent a year. Is there a way to add 1970 to each of the x-axis values? Thanks in advance.

댓글 수: 1

I tried
set(gca, 'XTickLabel',1970:2000)
which changed the axis to 1970-1976 instead of 1970-2000.

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

 채택된 답변

Star Strider
Star Strider 2018년 4월 27일

0 개 추천

One approach:
x = ...;
y = ...;
figure(1)
plot(x, y)
grid
xt = get(gca, 'XTick');
xtl = linspace(1970, 2000, numel(xt));
set(gca, 'XTick',xt, 'XTickLabel',xtl)

댓글 수: 2

Michaela Wood
Michaela Wood 2018년 4월 27일
Thank you!
Star Strider
Star Strider 2018년 4월 27일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Graphics Objects에 대해 자세히 알아보기

태그

질문:

2018년 4월 27일

댓글:

2018년 4월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by