How do I change axes font (heatmap)?

조회 수: 32 (최근 30일)
M.G.
M.G. 2020년 5월 28일
댓글: M.G. 2020년 5월 29일
Hello everyone,
I need to get a heatmap with all fonts being Times New Roman. I had no problems with heatmap values, more troubles with x axis font and I still can't change y axis font.
I am using this code:
h=heatmap(X, Y, C, 'FontName', 'Times New Roman');
h.xlabel('Something (unit)');
h.xlabel('FontName', 'Times New Roman');
h.ylabel('Something else (unit)');
h.ylabel('FontName', 'Times New Roman');
colormap(mymap)
And what I get is a heatmap with no y axis label. Everything else is alright. What am I missing here?

채택된 답변

Tommy
Tommy 2020년 5월 29일
Your code is crashing at this line:
h.xlabel('FontName', 'Times New Roman');
The x label is set properly because of the previous line, and the y label is never set because the following line is never reached.
The x label has Times New Roman font because you specified that the heatmap's font should be Times New Roman when you called heatmap(). So this should work:
h=heatmap(X, Y, C, 'FontName', 'Times New Roman');
h.xlabel('Something (unit)');
h.ylabel('Something else (unit)');
colormap(mymap)
  댓글 수: 3
Tommy
Tommy 2020년 5월 29일
Happy to help!
Heatmaps use the TeX text interpreter by default. To specify bolded text, put '\bf' before the text you would like to bold.
h=heatmap(X, Y, C, 'FontName', 'Times New Roman');
h.xlabel('\bf something');
h.ylabel('something \bf else');
colormap(mymap)
See here for general info about TeX.
See here for a complete list of properties you can set for a Heatmap.
M.G.
M.G. 2020년 5월 29일
That worked! Thank you very much :)

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by