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

2 vues (au cours des 30 derniers jours)
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?

Réponse acceptée

Torsten
Torsten le 11 Déc 2024
Modifié(e) : Torsten le 11 Déc 2024
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')

Plus de réponses (1)

Voss
Voss le 11 Déc 2024
Modifié(e) : Voss le 11 Déc 2024
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]'})

Catégories

En savoir plus sur Labels and Annotations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by