Plots in Matlab using Latex interpreter

46 ビュー (過去 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 Center および File ExchangeLanguage Support についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by