Is it possible to apply Latex formatting in heatmaps?

12 vues (au cours des 30 derniers jours)
Haoyang Lyu
Haoyang Lyu le 15 Mai 2018
Réponse apportée : Shlok le 24 Oct 2024 à 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?

Réponses (1)

Shlok
Shlok le 24 Oct 2024 à 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:

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by