Is it possible to apply Latex formatting in heatmaps?

6 次查看(过去 30 天)
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
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 CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by