轴标签中的希腊字母不起作用 [英] Greek letters in axes labels are not working
问题描述
我正在尝试在情节的xlabel中使用希腊字母.互联网上的每个解决方案都说Matlab将接受tex.但是,我的x轴不是德尔塔符号,而是简单地标记为'D'
I'm trying to use Greek letters in my xlabel of a plot. Every solution on the internet says that Matlab will accept tex. But instead of the delta-symbol my x-axis is simply labeled 'D'
a = plot(0:40, y);
hold on
plot(delta_T,brechkraft, 'x')
errorbar(delta_T, brechkraft,delta_b,'x');
title('2mm Oelschicht');
xlabel('\Delta');
ylabel('Brechkraft D in 1/cm');
annotation('textbox', [.2 .8 .1 .1],...
'String', {'Fit: f(x) = m*x + b', ['m = ', num2str(p(1)) ], ['b = ', num2str(p(2)) ]});
shg
hold off
saveas(a, 'abc1.png','png');
推荐答案
有点好奇,您的语法似乎还不错.您是否搞砸了系统的某些字体?或者,您的'interpreter'
设置为none
(文档文字道具)?
It's a little curious, your syntax seems alright. Have you screwed up some fonts of your system? Or maybe your 'interpreter'
is set to none
(doc text props)?
用(hx
= xlabel的句柄)进行检查:
Check it with (hx
= handle of xlabel):
get(hx, 'Interpreter')
并设置为:
set(hx, 'Interpreter', 'tex')
如果这不起作用,作为第一种解决方法,您可以尝试激活 Latex解释器,而不是通常的默认tex
.
If that is not working, as a first workaround you could try to activate the Latex interpreter instead of the usually default tex
.
x = 0:40;
y = x.^2;
plot(y,x, 'x')
title('\alpha \beta \gamma');
hx = xlabel('Symbol $\sqrt{\Delta}$ ','interpreter','latex');
hy = ylabel('Symbol $\sqrt{\epsilon}$','interpreter','latex');
但是实际上对于简单的希腊字母来说,这是没有必要的!
使用默认的tex
解释器:
hx = xlabel('\Delta');
hy = ylabel('\epsilon');
也在工作:
但无法与乳胶语法delta
一起使用:
but used with latex syntax delta
is not recognized anymore:
xlabel('Symbol $\sqrt{\Delta}$ ','interpreter','tex');
ylabel('Symbol $\sqrt{\epsilon}$','interpreter','tex');
其他想法:
当您键入get(0,'DefaultAxesFontName')
时,它将返回什么字体?
将其设置为 Helvetica 或 Arial 时可以使用吗?
What font does it return when you type: get(0,'DefaultAxesFontName')
?
Does it work when you set it to Helvetica or Arial?
set(0,'DefaultAxesFontName','Helvetica');
据报道,在某些系统(例如 Ubuntu 12.xx)上,您需要先安装 tex字体.
It is also reported that on some systems (e.g. Ubuntu 12.xx) you need to install tex fonts first.
这篇关于轴标签中的希腊字母不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!