I want to set ticks to my heat map figure. I don't find any options to do it. It has automatically set it with numbers. also I want to add subscripts to the values inside the boxes.

 채택된 답변

Chunru
Chunru 2022년 7월 1일

1 개 추천

It seems that "heatmap" has no properties for changing display text. You can use imagesc instead:
data = rand(4);
imagesc(data); colorbar
h = gca;
h.XTick= 1:4;
h.XTickLabel = ["A", "B", "C", "D"];
[xx, yy] = meshgrid(1:4, 1:4);
str = string(data(:));
str(1) = str(1)+"^B"; % Now you can specify the text anyway you like. This is an example
text(xx(:), yy(:), str, 'HorizontalAlignment', 'center')

댓글 수: 4

Roja Eliza
Roja Eliza 2022년 7월 6일
Thank you. It works.
Roja Eliza
Roja Eliza 2022년 7월 13일
I have a issue here. I am currently unable to change the colour scheme from blue to red
Chunru
Chunru 2022년 7월 13일
편집: Chunru 2022년 7월 13일
try colormap(jet) or colormap(hot)
doc colormap for more help
Roja Eliza
Roja Eliza 2022년 7월 13일
what you have mentioned are in built color codes. I want the color grading to be from red to blue as given in my first picture. aslo with this code I am unable to make the background colour to be white instead of blue( grids with zero values). with heat map i used a file exchange but for this the exchange is not working

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

추가 답변 (1개)

Chunru
Chunru 2022년 6월 30일

1 개 추천

cdata = rand(3,3);
h = heatmap(cdata);
h.XData = ["A", "B", "C"];
h.YData = ["A_1", "B_1", "C_1"];

댓글 수: 3

Roja Eliza
Roja Eliza 2022년 6월 30일
Thanks it works. How can I add subscriptsor suprscripts to the values inside the boxes?
Chunru
Chunru 2022년 6월 30일
Can you explain what you want exactly?
Roja Eliza
Roja Eliza 2022년 6월 30일
I want to insert letters or numbers as power of the numbers as in picture

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

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

질문:

2022년 6월 30일

댓글:

2022년 7월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by