Remove data labels in a heatmap

조회 수: 156 (최근 30일)
Dora Velcsov
Dora Velcsov 2019년 11월 1일
편집: Md Nazmul Anam 2023년 12월 13일
I am using a heatmap containing a grid of 1000x1000 points. The data values are displayed on the x and y axis, which is too much; they overlap since there are too many. I would like to remove all data and keep only the xlabel, ylable, and title with a larger font size. I am not sure how to change the font size either. I tried several things without luck.
Here is my command where "a" is the 1000x1000 matrix.
heatmap(a,'xlabel','\mu','ylabel','\nu','title',['Frequency of (\mu, \nu) for ','\epsilon = ',num2str(epsilon)]);
Thank you.

채택된 답변

Star Strider
Star Strider 2019년 11월 1일
If you just want to remove them, try this:
hmh = heatmap(a,'xlabel','\mu','ylabel','\nu','title',sprintf('Frequency of (\\mu, \\nu) for \\epsilon = %.2f',epsilon));
Ax = gca;
Ax.XDisplayLabels = nan(size(Ax.XDisplayData));
Ax.YDisplayLabels = nan(size(Ax.YDisplayData));
They don’t appear to have any properties specific to them (such as 'FontSize') that you can change.
  댓글 수: 3
Star Strider
Star Strider 2019년 11월 1일
As always, my pleasure!
Yogev Hadad
Yogev Hadad 2023년 6월 8일
Sorry for the late answer ( New user, for the benefit of future questioners):
You can use the following parameter:
heatmap(....,'CellLabelColor','none');
Works like a charm...
Godd luck!

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

추가 답변 (3개)

Shipra Jain
Shipra Jain 2020년 4월 29일
Hi,
Is there a way to show only some selective labels on Yaxis?
E.g. I have about 120 labels from 1970-2090. I would like only 1970, 1980, 1990....2090 to appear and switch off the other ones. Is that possible?
Thanks in advance.

Deepali Kushwaha
Deepali Kushwaha 2023년 6월 8일
To remove all xlabel, ylabel and tickslabel:
heatmap(arr,'CellLabelColor','none')
In case you want to retain all labels except xticklabel:
heatmap(arr,'XDisplayLabels',NaN*ones(length(arr),1))
  댓글 수: 1
Md Nazmul Anam
Md Nazmul Anam 2023년 12월 13일
편집: Md Nazmul Anam 2023년 12월 13일
Thanks a lot! This is the only solution out of 10s at least which solved the issue without messing something else in my plot!

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


Pingsheng Ren
Pingsheng Ren 2020년 12월 17일
Ax.CellLabelColor='none';

카테고리

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