labeling data sections on a graph

조회 수: 13 (최근 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