LaTex interpreter in Heatmap ax-label

11 Ansichten (letzte 30 Tage)
Andrea Medaglia
Andrea Medaglia am 6 Mai 2021
Beantwortet: Benjamin Kraus am 20 Sep. 2023
I want to use the LaTex interpreter in the xlabel and ylabel of a Heatmap plot.
I know how to do it for the plot() command, where I just have to write (it is just an example, and it works):
plot(x, f(x))
xlabel('$x$','Interpreter','latex')
ylabel('$f(x)$','Interpreter','latex')
The command heatmap() doesn't seem to work like the plot() command. Here's the code I'm using, where the variable Err is a MxM matrix:
heatmap(M,M,Err)
xlabel('$M_{1}$','Interpreter','latex')
ylabel('$M_{2}$','Interpreter','latex')
from which I receive the following error code:
Error using matlab.graphics.chart.Chart/xlabel
Too many input arguments specified when using xlabel with heatmap.
If I don't write the string 'Interpreter','latex' leaving just
heatmap(M,M,Err)
xlabel('$M_{1}$')
ylabel('$M_{2}$')
the code works but the label looks like in the figure:
  3 Kommentare
Andrea Medaglia
Andrea Medaglia am 6 Mai 2021
I just tried, but nothing changes. I see the same things of the question.
Walter Roberson
Walter Roberson am 6 Mai 2021
If I recall correctly, you cannot set the Interpreter for heatmap objects.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Benjamin Kraus
Benjamin Kraus am 20 Sep. 2023
Starting in MATLAB R2023b, the HeatmapChart now has an Interpreter property.
h = heatmap(rand(30));
h.XLabel = '$M_{1}$';
h.YLabel = '$M_{2}$';
h.Interpreter = 'latex';

Weitere Antworten (1)

Scott MacKenzie
Scott MacKenzie am 6 Mai 2021
h = heatmap(M,M,Err);
h.XLabel = 'M{_1}';
h.YLabel = 'M{_2}';
  11 Kommentare
Andrea Medaglia
Andrea Medaglia am 6 Mai 2021
Any suggestions to overcome these issues? Thanks for the answers, btw.
Scott MacKenzie
Scott MacKenzie am 6 Mai 2021
No really. It seems, as noted in a comment from Walter, that you can't set the Interpreter for heatmap objects.
You might consider re-stating your objective, perhaps in another question, without reference to latex.

Melden Sie sich an, um zu kommentieren.

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by