MATLAB: Heatmap – number of decimal places on x-axis

decimal placesheatmap

Hello everyone,
I've created a heatmap with x-axis values changing from 1.0 to 4.0 with the increment of 0.5. By default, these values are displayed on the x-axis as 1, 1.5, 2, 2.5 etc. Is there a way to change all of them to have one decimal place, i.e., 1.0, 1.5, 2.0, 2.5 etc.?

Best Answer

Similar to Walter Roberson's answer but does not require undocumented methods (and avoids the associated warning).
h = heatmap(__);
h.XDisplayLabels = compose('%.1f',str2double(h.XDisplayLabels));