How do I define the y axis of imagesc as integers and not fractions?

조회 수: 6 (최근 30일)
Nadatimuj
Nadatimuj 2022년 3월 11일
댓글: Nadatimuj 2022년 3월 12일
I have 2x1e7 data but imagesc makes the y axis range from 0.5 to 2.5. How can I make it 0 to 2? And what is the reason the default is 0.5 to 2.5 when there are 2 data?
  댓글 수: 2
Simon Chan
Simon Chan 2022년 3월 11일
imagesc(C) displays the data in array C as an image that uses the full range of colors in the colormap. Each element of C specifies the color for one pixel of the image. The resulting image is an m-by-n grid of pixels where m is the number of rows and n is the number of columns in C. The row and column indices of the elements determine the centers of the corresponding pixels.
The center of the pixels in your case are 1.0 and 2.0 and the width of each pixel is 1 pixel (0.5 pixels on each side). So it starts from 0.5 to 1.5 for the first pixel and 1.5 to 2.5 for the second one.

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

채택된 답변

DGM
DGM 2022년 3월 11일
What Simon says is correct. If you only want the center ticks, you can specify them explicitly:
A = rand(2,6);
imagesc(A);
yticks([1 2])

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by