How to plot the temperature unit which is small circle raised at the left of C upper case?

2 ビュー (過去 30 日間)
I have a plot where it must have a titel as in the following MATLAB command:
title({'Exit Cold Carrier Temperature [ \circC]', ' Cooling Capacity [W]'})
when I run the plot command, the result I get is obtained with no small circle (the resulted plot is attached) .
Kindly advise what is the correct way to have the Celsius unit as small circle raised to the left of C upper case?

採用された回答

Torsten
Torsten 2024 年 12 月 11 日
編集済み: Torsten 2024 年 12 月 11 日
Maybe by adding the interpreter ? In R2024b, your title is correctly plotted without any modifications.
x=0:0.1:1;
y=x.^2;
plot(x,y)
title({'Exit Cold Carrier Temperature [\circC]', ' Cooling Capacity [W]'},'Interpreter','tex')

その他の回答 (1 件)

Voss
Voss 2024 年 12 月 11 日
編集済み: Voss 2024 年 12 月 11 日
In order to have '\circ' be rendered as the degree symbol in a text object's String, the text object's Interpreter must be 'latex'. 'latex' is the default text interpreter, so unless you changed the default or specified a different interpreter for this particular title, the degree symbol will be rendered. Given that the code shown doesn't set the interpreter, I'll assume somewhere else you changed the defaultTextInterpreter root property to 'none'.
An alternative to using '\circ' is to put the degree symbol directly in your text's String, either using char(176) or °, in which case the text object's interpreter can be 'tex' or 'none' for this particular String.
% set the default root defaultTextInterpreter property to 'none', to
% attempt to reproduce the problem:
set(0,'defaultTextInterpreter','none')
% create a figure with 4 tiles:
figure('Position',[10 10 800 500])
tiledlayout(2,2)
% problem: default 'none' interpreter:
nexttile()
title({'Exit Cold Carrier Temperature [ \circC]', ' Cooling Capacity [W]'})
% solution 1: explicitly using 'tex' interpreter for this text object:
nexttile()
title({'Exit Cold Carrier Temperature [ \circC]', ' Cooling Capacity [W]'},'Interpreter','tex')
% solution 2a: using char(176):
nexttile()
title({['Exit Cold Carrier Temperature [ ' char(176) 'C]'], ' Cooling Capacity [W]'})
% solution 2b: using °:
nexttile()
title({'Exit Cold Carrier Temperature [ °C]', ' Cooling Capacity [W]'})

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by