MATLAB: How to remove color bar in the matlab heatmap and add one to the whole subplot

axesaxes labelheatmap

I am making a subplot that has 4 heatmaps. I want to remove individual color bar and add one to the right end of the subplot.
I also want to remove the axes label for each individual heatmap and add one to the bottom as x label and one to the left as y label.
Any idea?

Best Answer

ERRATUM:
My bad, I had other figures around and didn't realize the heatmap object is child of the figure, not of an axes on the figure as most other plot objects have historically been.
Your h2 variable is the handle to the heatmap object you created--it's already an object; use it as is, don't muck on it and make a struct out of it.
hHM=heatmap(...);
hHM.XLabel=[]; hHM.YLable=[];
If you instead mean the actual cell labels, those apparently cannot be removed--altho don't know why one would want to:
>> ylbls=hHM.YDisplayData; % retrieve labels array for convenience to have some...
>> ylbls(3)={''}; % clear one of 'em...
>> hHM.YDisplayData=ylbls; % try to write -- fails (not too surprisingly I'd think)
Error using matlab.graphics.chart.HeatmapChart/set.YDisplayData
Empty strings and strings containing only space are invalid y values.
>>
Guess one could change .FontColor color to figure background and would disappear visually...
Related Question