Specifying interpreter type for heatmap

6 ビュー (過去 30 日間)
Deepa Maheshvare
Deepa Maheshvare 2020 年 3 月 9 日
回答済み: Jayanti 2024 年 10 月 7 日
I have the following heatmap and I want to set the title interpreter to none
load patients
tbl = table(LastName,Age,Gender,SelfAssessedHealthStatus,...
Smoker,Weight,Location);
h = heatmap(tbl,'Smoker','SelfAssessedHealthStatus');
ttl = "df_cd";
h.Title = ttl;
%h.Title.Interpreter = 'none'; Doesn't work
set(groot,'defaulttextinterpreter','none');
set(groot,'defaultAxesTickLabelInterpreter','none');
set(groot,'defaultLegendInterpreter','none');
Any suggestions on how to set the title interpreter to none?
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 3 月 9 日
How does this differ from https://www.mathworks.com/matlabcentral/answers/509464-interpreter-type-for-specifying-heatmap-title
Deepa Maheshvare
Deepa Maheshvare 2020 年 3 月 9 日
編集済み: Deepa Maheshvare 2020 年 3 月 9 日
Thanks. It's a duplicate and I have deleted the other question.

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

回答 (1 件)

Jayanti
Jayanti 2024 年 10 月 7 日
Hi Deepa,
I understand that you want to display the title text exactly as typed, without interpreting any special characters. But heatmap object in MATLAB does not directly support changing the text interpreter for its title for the version you are using i.e R2019b.
So special characters like underscore will be treated as formatting commands. But since you want to display your title text literally you can use annotation to create custom title. For that first you must clear default title to remove any overlap with custom title by following command:
h.Title = '';
Then you can use annotation function to place a text box at the top of the figure. And set the interpreter property as none to ensure the text is displayed exactly as entered.
annotation('textbox', [0.4, 0.95, 0.2, 0.05], 'String', 'df_cd', ...
'EdgeColor', 'none', 'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'middle', 'FontSize', 12, 'Interpreter', 'none');
I am also attaching MathWorks documentation link on annotation for your reference:
Hope it helps!

カテゴリ

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