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
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
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!