Plots in Matlab using Latex interpreter

63 views (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 17 Jun 2018
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 Comments
Tony Castillo
Tony Castillo on 26 Oct 2021
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 on 26 Oct 2021
txt = {'Gas m^3: ';'Petrol Lts: '; 'PV W·h: '};

Sign in to comment.

More Answers (0)

Categories

Find more on Language Support in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!