Display values on heatmap plot - they disappear as the plot shrinks

조회 수: 99 (최근 30일)
I am trying to make a heatmap where the values of the cells are displayed as well, not only the color. Now this basically works - however, as soon as I shrink the figure, the numbers disappear and I am left with colourful but empty cells. I guess this has to do with the text size, but how can I adapt that one?
This is the example code (just a simple heat map):
heatmap(dfd_ptp, 'Colormap', jet, 'ColorbarVisible', 'on', 'XLabel', 'Time', 'YLabel', monthstr)

채택된 답변

Benjamin Kraus
Benjamin Kraus 2018년 2월 23일
The font size of the cell labels on the heatmap automatically scale so that they don't overrun the individual cells (and so the labels don't overlap one another). They will automatically turn off when the font size gets too small to read. The threshold at which the cell labels turn off is hard-coded, there is no way to modify that setting. In addition, the cell labels will all turn off as soon as any of the labels are too big to fit (i.e. they all turn off at the same time, not one-by-one).
If the labels did not turn off, at some point they would just become black dots in the center of the cells, which would obscure the colors in the cells. I know that setting the FontSize will make the axes labels smaller, but out of curiosity, what font size would you use for your cell labels that fit inside the cell, but is large enough to read?
Also, if you could control the font size of the cells, which would you prefer:
  • Be able to specify the cell label font size independent of the axes label font size
  • Be able to adjust the minimum cell label font size before the labels are considered "too small to read" and are are shut off automatically?
There is one potential solution, depending on your particular data: You may be able to modify the CellLabelFormat to generate shorter cell labels.
  댓글 수: 1
Stefanie Aebi
Stefanie Aebi 2018년 2월 26일
Hi and thank you for your reply. I'm not sure whether I remember correctly, but I think I put 5pt or 6pt and then I still got cell Labels. However, that didn't look very nice on the axes... My favourite Option would thus be the first one: specify the cell Label font size Independent of the axes Label font size. I guess that would resolve the Problem, even though I will get small cell labels

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

추가 답변 (2개)

Walter Roberson
Walter Roberson 2018년 2월 1일
  댓글 수: 2
Stefanie Aebi
Stefanie Aebi 2018년 2월 1일
편집: Stefanie Aebi 2018년 2월 1일
Thanks for your Suggestion! That already solves part of the Problem :-) However, if I adapt FontSize, the axis Labels shrink as well (because FontSize is specified for all text), which is something I don't really want. Is there a way to adapt only the fontsize of the cell labels?

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


Farid Samara
Farid Samara 2020년 10월 23일
I am trying to use heatmap to plots tables in matlab. I really like the idea of being able to visualize the numbers. But it is also very important to me to show the numbers. Is is possible to should the cell numbers vertically? That could also make a huge difference?
Is there another function I could use to visualize tables?
Thanks
Farid

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by