Greek letters in axes labels are not working

后端 未结 1 542
-上瘾入骨i
-上瘾入骨i 2020-12-17 05:32

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

相关标签:
1条回答
  • 2020-12-17 06:08

    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.

    0 讨论(0)
提交回复
热议问题