Why does the heatmap chart color some numeric values differently?

조회 수: 6 (최근 30일)
I want to understand why the heatmap chart color tabulated numbers differently. Does the white values represent high values? If you check the example below, you will see that 24 is colored in white while the other number remain in black. How can I control this coloring option based on custom conditions?
openExample('graphics/CreateHeatmapFromTabularDataExample')
  댓글 수: 1
Thomas Shaw
Thomas Shaw 2023년 4월 26일
@chicken vector gives good advice: the handle h returned by a graphics command generally has useful hints about what you can customize about how it is displayed. Sometimes it's still not obvious what all of the available options are, though. In that case there is often more detailed documentation that you can access by
doc h
If you run that after the example you pointed to, and go down to the section about CellLabelColor, you will see
> Text color for data labels, specified as 'auto', an RGB triplet, a hexadecimal color code, a color name, or a short name. The default value of 'auto' chooses an appropriate text color, depending on the color of each heatmap cell. If you do not want the labels to display, specify 'none'.
So in other words, when this is set to auto (which is the default), it will choose a light color text for cells whose backgrounds are dark, and vice versa. It looks like there is no documented/straightforward way to choose particular colors for particular ranges of values.

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

채택된 답변

chicken vector
chicken vector 2023년 4월 26일
편집: chicken vector 2023년 4월 26일
>> h = heatmap(tbl,'Smoker','SelfAssessedHealthStatus','CellLabelColor','Black');
% ^----------------------^
A quick tip for next time.
After you create the heatmap stored in teh variable h, you type h in the command window and see all public properties of the object.
Typically, from the name of the properties you will easily find what you are looking for.

추가 답변 (0개)

카테고리

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