How can i print z axis values on a pcolor plot

조회 수: 8 (최근 30일)
harshpurohit11
harshpurohit11 2018년 8월 15일
댓글: harshpurohit11 2018년 8월 16일
x = [0,10,20,30], y = [100,210,300,500] z = [0 0 0 1; 0 0 1 0; 1 1 0 0; 1 0 0 0];
i tried generating a pcolor plot for above variables such as
pcolor(x, y,z);colormap summer; colorbar
Now I need to display the z values on the plot for every box displayed in the plot and I havent been able to find a way to do so

채택된 답변

jonas
jonas 2018년 8월 15일
Something like this?
[X,Y]=meshgrid(x,y);
hold on;
pcolor(x, y,z);
colormap summer;
colorbar
text(X(:),Y(:),num2cell(z(:)'))
  댓글 수: 3
jonas
jonas 2018년 8월 16일
편집: jonas 2018년 8월 16일
I am not sure I understand. Can you give me a hint? Perhaps an image?
I'm speculating now but perhaps you can replace the last line of code with this:
text(X(:),Y(:),sprintfc('%d',z(:)))
Or do you want to change the fontsize? if so:
text(X(:),Y(:),sprintfc('%d',z(:)),'fontsize',5)
harshpurohit11
harshpurohit11 2018년 8월 16일
This is perfect. Thanks a lot :)

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by