Is it possible to apply Latex formatting in heatmaps?

12 Ansichten (letzte 30 Tage)
Haoyang Lyu
Haoyang Lyu am 15 Mai 2018
Beantwortet: Shlok am 24 Okt. 2024 um 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?

Antworten (1)

Shlok
Shlok am 24 Okt. 2024 um 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:

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by