Display values of each element in imagesc
97 ビュー (過去 30 日間)
古いコメントを表示
I have a 16 x 16 array of values between 0 and 40. I would like to display this using imagesc, but I would also like to superimpose the decimal value of each element in its corresponding square. I would end up with a 16 x 16 array of colored (per mapping) squares, each with the square's value in decimal text. Is there an easy / convenient way to do this?
If there was a version of "disp" that I could apply to a figure after imagesc that might work, but I can't find one.
Thanks
0 件のコメント
採用された回答
その他の回答 (1 件)
Walter Roberson
2021 年 10 月 11 日
Is there an easy / convenient way to do this?
No. But it can be done.
Note: there is no one text font color that will contrast nicely with all of the underlaying colors -- not unless you colormap() in a different colormap such as copper() that you can find a simple text color for.
A = randi([0 40], 16, 16); %sample data
[R, C] = ndgrid(1:size(A,1), 1:size(A,2));
R = R(:); C = C(:) - 1/4;
%rows are Y values, columns are X values !
imagesc(A)
vals = A(:);
mask = vals <= 20;
text(C(mask), R(mask), string(vals(mask)), 'color', 'w')
text(C(~mask), R(~mask), string(vals(~mask)), 'color', 'k')
A
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!