フィルターのクリア

Changing the properties of a heatmap title

38 ビュー (過去 30 日間)
Tom Shlomo
Tom Shlomo 2019 年 12 月 16 日
コメント済み: Julian Neundorf 2023 年 2 月 11 日
For standard axes, the title property is a Text object, so properties such as Interpreter and FontSize can be setted directly.
However it seems that for heatmap objects, the title property is just a string.
Is there any way to modify the title properties? (for example setting the Interpreter to latex)
(The same applies also to XLabel and YLabel)

採用された回答

Adam Danz
Adam Danz 2019 年 12 月 16 日
編集済み: Adam Danz 2019 年 12 月 16 日
Matlab's heatmap() function (released 2017a) is notoriously difficult to customize. The handles to the title and axis labels are not accessible. You can follow the advice in this answer which shows how to overlay an invisible axes on top of the heatmap where you can customize the title and axis labels as you normally would.
  2 件のコメント
DanielFromIllinois
DanielFromIllinois 2021 年 1 月 7 日
This makes me sad inside.
Adam Danz
Adam Danz 2021 年 1 月 7 日
編集済み: Adam Danz 2021 年 1 月 7 日
> This makes me sad inside.
Check out these 3 alternatives to heatmap and 2 more examples. These alternatives avoid the restrictions of heatmap().
Now let's turn that frown upside down!
% rotating frown face
fig = figure('Units','Points','Color','w','menu','none');
sz = 200;
fig.Position(3:4) = [sz,sz]*1.2;
movegui(fig)
ax = axes(fig,'Units','Normalize','Position',[0 0 1 1]);
axis(ax,'off')
axis(ax,'equal')
xlim(ax,[-1,1])
ylim(ax,[-1,1])
hold(ax,'on')
scatter(ax,0,0,sz.^2,'y','filled')
txh = text(ax,0,0,char([55357,56897]),'HorizontalAlignment','Center',...
'VerticalAlignment','middle','FontSize',sz*1.13); % Helvetica, Windows 10.
while isvalid(fig)
txh.Rotation = txh.Rotation - 2;
drawnow; pause(.01)
end

サインインしてコメントする。

その他の回答 (1 件)

Sunny
Sunny 2022 年 12 月 13 日
I can't remember where I originally found this solution but I needed this just now and found it in one of my scripts. To access and change the property of title, axis labels etc. use for example:
h=heatmap(...)
set(struct(h).Axes.Title,'FontWeight','normal')
Matlab will throw a warning but it works fine.
  1 件のコメント
Julian Neundorf
Julian Neundorf 2023 年 2 月 11 日
Changing the FontSize the same way works perfectly too! Thanks a lot!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by