필터 지우기
필터 지우기

How can I make the x and y labels start at the origin?

조회 수: 14 (최근 30일)
Al Gut
Al Gut 2021년 1월 28일
편집: Al Gut 2021년 1월 29일
This is my code to plot a matrix with imagesc:
imagesc(f);
set ( gca, 'ydir', 'normal' )
colorbar
ticks=[0:12.5:100];
xticks(ticks);
xticklabels({100:100:800});
yticks(ticks);
yticklabels({10:10:80});
--- I want the axis to start in the origin with x=100 and y=10 but it start to write labels one xtick later. How can I fix that? I want to have my first tick label in the origin and with a value of x=100, y=10.

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 1월 28일
The issue is that you are specifying your first tick to be at 0. Image X and Y values come from the column and row indices of the array, respectively. MATLAB does not use an index of 0. It starts at 1. Therefore, your first tick is getting skipped. Start your ticks at one instead.
Also note that you have specified 9 tick locations but only 8 labels.
Z = 10 + peaks(100);
imagesc(Z)
set ( gca, 'ydir', 'normal' )
colorbar
ticks=linspace(1,100,8);
xticks(ticks);
xticklabels({100:100:800});
yticks(ticks);
yticklabels({10:10:80});

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by