matrix values as text on plot

조회 수: 16 (최근 30일)
Paul
Paul 2012년 2월 23일
댓글: Saeed Bello 2016년 12월 20일
Hello all,
I don't really know how to ask this question, but I'll try my best.
From a 20*20 matrix I used griddata and then pcolor to plot a figure just like this one:
I now would like to insert the matrix as text on top of the figure (just like you can see in the link above).
Of course I can use the "text" function and insert all the values one by one. But I'm sure there is an easyer way to do it!
I tried using clabel, but I couldn't find a way to label all the matrix values.
Your help would be much appreciated!
Paul

채택된 답변

Andrew Newell
Andrew Newell 2012년 2월 23일
You could do all the text commands in a loop, for example:
A = randn(20);
x = linspace(0,1,20); y = x;
pcolor(x,y,A); colormap summer
for ii=4:4:16
for jj = 4:4:16
text(x(ii),y(jj),num2str(A(ii,jj),2))
end
end
  댓글 수: 1
Paul
Paul 2012년 2월 23일
Thank you Andrew for your reply.
After I asked the question I spent some more time thinking about it and found the exact solution for my problem. I hadn't had time to put it here.
Sometimes the best solution is the simpler.
Best regards,

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

추가 답변 (1개)

fei
fei 2015년 1월 28일
Hi Paul.
i'm facing the same problem.
Can you kindly share with me how do you overcome it?
Thank you in advance
  댓글 수: 1
Saeed Bello
Saeed Bello 2016년 12월 20일
The answer has been answered by Mathswork Support team on the link below: https://www.mathworks.com/matlabcentral/answers/91384-how-can-i-display-the-numerical-values-of-each-cell-as-text-in-my-pcolor-plot

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by