LaTex interpreter in Heatmap ax-label
이전 댓글 표시
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
Jonas
2021년 5월 6일
did you try something like
set(findall(gcf,'-property','Interpreter'),'Interpreter','latex')
?
Andrea Medaglia
2021년 5월 6일
Walter Roberson
2021년 5월 6일
If I recall correctly, you cannot set the Interpreter for heatmap objects.
채택된 답변
추가 답변 (1개)
Scott MacKenzie
2021년 5월 6일
h = heatmap(M,M,Err);
h.XLabel = 'M{_1}';
h.YLabel = 'M{_2}';
댓글 수: 11
Walter Roberson
2021년 5월 6일
That looks like TeX interpreter, not LaTex.
Scott MacKenzie
2021년 5월 6일
Yes, I'm using the (default) TeX interpreter. I assuming Andrea's real goal is just to get the appropriate labels in the axes.
Walter Roberson
2021년 5월 6일
"I want to use the LaTex interpreter in the xlabel and ylabel of a Heatmap plot."
Seems pretty specific.
Andrea Medaglia
2021년 5월 6일
Scott MacKenzie
2021년 5월 6일
OK, I'm still not sure what you want. I assume it's one of the following:

Can you clarify please?
Andrea Medaglia
2021년 5월 6일
Scott MacKenzie
2021년 5월 6일
Hmm, your question didn't mention anything about fonts. Sorry if I misunderstood.
Andrea Medaglia
2021년 5월 6일
Walter Roberson
2021년 5월 6일
Also the spacing and bold rendering are different for latex compared to tex
Andrea Medaglia
2021년 5월 6일
Scott MacKenzie
2021년 5월 6일
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.
카테고리
도움말 센터 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
