필터 지우기
필터 지우기

changing ticks position on the graph

조회 수: 8 (최근 30일)
Wade
Wade 2023년 3월 28일
댓글: Wade 2023년 3월 29일
Hi,
I have a problem that seems to be easy. I have created a heat map in form of matrix but the scale I want to set from -400 to 400. I was able to change the axes numbers but the ticks are at the centre of each square instead to be in between them. How to do it?
Thank you,
Regards,
Matti
  댓글 수: 3
DGM
DGM 2023년 3월 28일
편집: DGM 2023년 3월 28일
If the SW element of the heatmap represents data at (-400, -400), then that's where they're supposed to be in order to communicate that relationship.
If that element represents data at (-440, -440), then you might want to fix your x,y data so that it actually corresponds.
Wade
Wade 2023년 3월 29일
thank you for your advice!
BW,
Matti

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

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2023년 3월 29일
If you have coordinates for the edges of the cdata-elements then you can either adjust things manually to get what you want:
dx = 80;
dy = 80;
heatmap(x+dx/2,y+dy/2,cdata)
set(gca,'xtick',x,'ytick',y)
Or perhaps use pcolor instead of heatmap:
dx = 80;
dy = 80;
pcolor([x(:)',x(end)+dx],[y(:),y(end)+dy],cdata([1:end,end],[1:end,end])),shading flat
That should be rather close, I hope. This centre-of-pixel vs edge-of-pixel is a problem that will always persist and never have a solution that satisfies every user in all cases - we just have to learn to work around the given behaviours to get the output that corresponds to our use-cases.
HTH
  댓글 수: 1
Wade
Wade 2023년 3월 29일
I will try these codes,
thanks a lot,
BW,
Matti

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

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by