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

조회 수: 10 (최근 30일)
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?
  댓글 수: 1
dpb
dpb 2020년 4월 13일
편집: dpb 2020년 4월 13일
Presuming R2019b or later, use tiledlayout instead of subplot. If not, R2018b introduced sgtitle. Prior to that there are File Exchange submittals for the purpose.
That works for the titles.
For colormap the only easy way will likely be the tiledlayout route -- you should probably be able to associate a colormap with the overall container and turn off for the individual heatmaps. Haven't tried tiledlayout myself yet.
The "actual cell labels" are the labels on the individual heatmap cells associated with the heatmap object, not the axes labels. That's 'XDisplayData' and XDisplayDataLabels'
Ewww... just realized a problem--hHM is a child of the figure, not of an axes object in the figure. Use 'X/YLabel' in the HM object.
>> hHM.XLabel=''; % clear HM object x label

댓글을 달려면 로그인하십시오.

채택된 답변

dpb
dpb 2020년 4월 12일
편집: dpb 2020년 4월 13일
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...
  댓글 수: 3
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020년 4월 12일
By the way I edited the question so that you can better give suggestion.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by