Why does the heatmap chart color some numeric values differently?

6 Ansichten (letzte 30 Tage)
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 Kommentar
Thomas Shaw
Thomas Shaw am 26 Apr. 2023
@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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

chicken vector
chicken vector am 26 Apr. 2023
Bearbeitet: chicken vector am 26 Apr. 2023
>> 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.

Weitere Antworten (0)

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by