Is it possible to apply Latex formatting in heatmaps?

12 ビュー (過去 30 日間)
Haoyang Lyu
Haoyang Lyu 2018 年 5 月 15 日
回答済み: Shlok 2024 年 10 月 24 日 7:38
I created a heatmap with function 'heatmap(xvalues,yvalues,cdata)'. It seems that latex expressions like '^', '_', etc. have not been interpreted in 'xvalues' and 'yvalues'. So I want to know how to display latex-format elements in the 'xvalues' and 'yvalues' position of heatmap? Or how to set xticklabels and yticklabels with latex format for heatmap?

回答 (1 件)

Shlok
Shlok 2024 年 10 月 24 日 7:38
Hi Lyu,
The support for controlling text interpreter (including LaTeX) for displayed text using the Interpreter property is added from R2023b. You can upgrade to R2023b or a later version to use this feature. I have attached the link of release notes of R2023b for further context:
You can set the “TickLabelInterpreter property of heatmap to latex for the tick labels to show the LaTeX-formatted elements. Here’s a sample implementation for the same:
% Sample data
xvalues = {'\alpha', '\beta', '\gamma', '\delta', '\epsilon'};
yvalues = {'\theta', '\lambda', '\mu', '\nu', '\omega'};
cdata = rand(5);
% Create heatmap
h = heatmap(xvalues, yvalues, cdata);
% Set the tick label interpreter to LaTeX
h.NodeChildren(3).TickLabelInterpreter = 'latex';
This method will ensure that the labels in both the x-axis and y-axis display correctly formatted LaTeX symbols.
To know more about heatmaps, refer to the following MathWorks Documentation link:

カテゴリ

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

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by