Greek letters in axes labels are not working

13,766

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 \beta \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.

Share:
13,766
Stein
Author by

Stein

I am currently a physics student at LMU University in Munich.

Updated on June 08, 2022

Comments

  • Stein
    Stein almost 2 years

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