Heatmap labels - not working?

11 views (last 30 days)
Simon Parten
Simon Parten on 21 Nov 2018
Edited: Adam Danz on 21 Nov 2018
mytable = table([1e6, 2e6, 3e6, 1.5e6, 2.5e6, 3.5e6]', ["v1", "v1","v1", "v2","v2","v2" ]', ["met1", "met2", "met3","met1", "met2", "met3"]', 'VariableNames', {'val', 'ver', 'metric'} );
heatmap(mytable,'ver','metric', 'ColorVariable','val','CellLabelFormat', '%.g')
heatmap(mytable,'ver','metric', 'ColorVariable','val','CellLabelFormat', '%,g')
First heatmap work... second doesn't produce labels. Can anyone tell me why?
Warning: Error updating HeatmapChart.
'ColorData' value must be a 4-row, uint8 matrix with the same number of columns as the length of the 'Strings' value.
Noie that according to the documentation for heatmap, the second line should produce a comma separated number in the boxes.
  1 Comment
Adam Danz
Adam Danz on 21 Nov 2018
Edited: Adam Danz on 21 Nov 2018
Looks like you found a bug. The comma option in
'CellLabelFormat', '%,g'
is not available in sprintf() or fprintf() and it doesn't function in heatmap(). Maybe it's a sign of features to come (which has been requested a lot in the forum).
Even when you try to change the formatting after plotting, you get an error.
h = heatmap(...)
h.CellLabelFormat = '%,4.4g'
Warning: Error updating HeatmapChart.
Invalid format.
The bug has been reported.
In the mean time, you could use %.f if you want to get rid of exponential notation.

Sign in to comment.

Answers (0)


Find more on Data Distribution Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by