Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
918 views
in Technique[技术] by (71.8m points)

matlab - Greek letters in axes labels are not working

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');
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)?

Check it with (hx = handle of xlabel):

get(hx, 'Interpreter')

and set it with:

set(hx, 'Interpreter', '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 eta gamma');

hx = xlabel('Symbol $sqrt{Delta}$  ','interpreter','latex');
hy = ylabel('Symbol $sqrt{epsilon}$','interpreter','latex');

enter image description here


But actually for simple greek letters, that is not necessary!

with the default tex interpreter:

hx = xlabel('Delta');
hy = ylabel('epsilon');

is working too:

enter image description here

but used with latex syntax delta is not recognized anymore:

xlabel('Symbol $sqrt{Delta}$  ','interpreter','tex');
ylabel('Symbol $sqrt{epsilon}$','interpreter','tex');

Other ideas:

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');

It is also reported that on some systems (e.g. Ubuntu 12.xx) you need to install tex fonts first.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...