MATLAB: How to change X and Y axis values on a heatmap.

axisheatmapMATLABxdisplaylabelydisplaylabel

Hi.
So I have a heatmap, that displays a 50 x 50 array of values. I want the X and Y Axis to go from 1 to 10 (with each value representing 5 of the previous), but right now, since I have a 50 x 50 array, each axis goes from 1-50. This is unsightly and I wan't to change this.
I have tried changing the XDispayLabel and YDisplayLabel in code, and in the editor after creating the heatmap, but to no avail.I kept on getting an error message saying that the cell was out of the dimensions of XDisplay or YDisplay.
Another question (Albeit, less important) is how to choose colors that are a bit easier to differentiate from, and how to set the limit of the colors to custom limits, since my values are very close together and are getting grouped up accordingly. I am running R2018a. Here is my code for the Heat map:
if true
% code
%heatmap
h = heatmap(total_cost, 'Colormap', parula(20), 'ColorbarVisible', 'on', 'XLabel', 'Installed MW of Solar (1000MW per Tick)', 'YLabel', 'Installed MW of Wind(1000MW per Tick)');
h.title(['Optimal Mix of Wind and Solar', 'FontSize', 30]);
h.xlabel(['Installed MW of Solar (1000MW per Tick)', 'FontSize', 24]);
h.ylabel(['Installed MW of Wind (1000MW per Tick)', 'FontSize', 24]);
h.XDisplayLabel[1:10:100];
h.YDisplayLabel[1:10:100];
end
Thank you in advance.

Best Answer

Hi Myles,
You can change the x axis and y axis values by providing them as input to heatmap.
Create numemric arrays x,y within the range required and provide them as arguments.
x=linspace(1,10,50);
y=linspace(1,10,50);
h = heatmap(x,y,total_cost, 'Colormap', parula(20), 'ColorbarVisible', 'on', 'XLabel', 'Installed MW of Solar (1000MW per Tick)', 'YLabel', 'Installed MW of Wind(1000MW per Tick)');
I am attaching the snapshot of a heatmap with 50x50 random values with x and y axis normalized to 1-10.
Thanks,
Aditya