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