Azzera filtri
Azzera filtri

labeling data sections on a graph

8 visualizzazioni (ultimi 30 giorni)
Batool Mutawe
Batool Mutawe il 12 Nov 2021
Risposto: DGM il 12 Nov 2021
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')

Risposte (1)

DGM
DGM il 12 Nov 2021
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)

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by