labeling data sections on a graph

10 ビュー (過去 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 Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by