Plots in Matlab using Latex interpreter

조회 수: 61 (최근 30일)
Ameer Ahmed
Ameer Ahmed 2018년 6월 17일
댓글: Walter Roberson 2021년 10월 26일
Hi
I want to insert a bar over a parameter in xlabel of plot for representing it as an average value. I have used Latex interpreter for this using command:
xlabel('Average throughput $\it{\bar{T}} \rm{(files/slot)}$','interpreter','latex');
set(get(gca,'XLabel'),'Fontname','Times new roman','FontSize',14);
When i excute the command, it doesn't change the font type to Times new roman rather a different font is displayed. Only the font size changes. I think the problem is with \bar{T}. I have changed to Tex and removed $ signs as well then it shows the same text as shown in xlabel.
I will be oblidged if someone could give me suggestion.

채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 17일
When you use $$ then that is Math mode, which uses a different font by default. To control the font inside Math mode, you need to embed font commands. See https://www.mathworks.com/matlabcentral/answers/321122-how-to-change-the-fontname-of-axes-labels-when-using-the-latex-interpreter#answer_251215
  댓글 수: 2
Tony Castillo
Tony Castillo 2021년 10월 26일
Dear Walter,
I got a similar issue but my code, does not give me an error or anything else. I have found the interpreter function for making more appealling the text which I am introducing to my pie chart, but it is not working properly.
Can you help me with any workaround to overcome the issue highlithed in the figure that I have shared.
I look forward to hearing from you
Best regards
x=[Gas, Petrol, PV_siliceLCA];
explode=[0 1 0];
p=pie(x, explode);
pText = findobj(p,'Type','text');
percentValues = get(pText,'String');
txt = {'Gas_m^3: ';'Petrol_Lts: '; 'PV_W·h: '};
combinedtxt = strcat(txt,percentValues);
pText(1).String = combinedtxt(1);
pText(2).String = combinedtxt(2);
pText(3).String = combinedtxt(3);
Walter Roberson
Walter Roberson 2021년 10월 26일
txt = {'Gas m^3: ';'Petrol Lts: '; 'PV W·h: '};

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Support에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by