labeling data sections on a graph

8 次查看(过去 30 天)
Batool Mutawe
Batool Mutawe 2021-11-12
回答: DGM 2021-11-12
I would like to add a label including each set of peaks in the graphs below (4 labels per graph).
this was my code.
load 'HCl_DCl_Complete'
ds=table2array(HCl_DCl_Complete);
wn=ds(:,1);
Trans=ds(:,2);
Abs= -log10(Trans/100);
subplot(2,1,1);
plot (wn, Abs, 'r-');
xlabel('Wavenumber $$\tilde{\nu} (cm^{-1})$$', 'Interpreter','latex')
ylabel('Absorbance')
title('In terms of Absorbance')
subplot(2,1,2);
plot (wn, Trans, 'k-');
xlabel('Wavenumber $$\tilde{\nu} (cm^{-1})$$', 'Interpreter','latex')
ylabel('Transmittance')
title('In terms of Transmittance')
%those are the labels I would like to add.
txt={'Fundamental DCl', 'Fundamental HCl', '1st Overtone DCl', '1st Overtone HCl'};
%I have tried it with this interval but it did not work.
text(wn(29120:end), Trans(29120:end), txt)
sgtitle('The IR spectrum of HCl and DCl')

回答(1 个)

DGM
DGM 2021-11-12
Consider the example:
[x,~,z] = peaks(100);
x = x(1,:);
z = z(50,:);
plot(x,z)
labels = {'dip 1','bump 1','bump 2'};
text([-1.1 -0.5 1.5],[-2.75 2.1 3.6],labels)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by