I would like to plot the subpeaks of my fitted peak. I have a composite peak with a main peak and a shoulder. I can fit and plot it, but i need the individual subpeaks which build up the spectra. How can I plot them too? My code is the following:
set term png
set fit quiet
set fit logfile "peakfitdatalog.txt"
do for[i = 0:20] for [j = 0:20] {
outfile = "testmap_Y".(sprintf('%02d_X%02d',j,i)).".png"
set output outfile
set xrange [900:1000]
x01=960
w1=10.64
a1=50000
mu1=0.90
x02=967
w2=10.64
a2=500
mu2=0.90
y0=350
y1=0.1
voigtfv(x)=y0+y1*x+a1*((2./pi)*w1/(4.*(x-x01)**2.+w1**2.))+a2*((2./pi)*w2/(4.*(x-x02)**2.+w1**2.))
fit voigtfv(x) "testmap_Y".(sprintf('%02d_X%02d',j,i)).".txt" via a1, a2, w1, w2, y0, y1
plot "testmap_Y".(sprintf('%02d_X%02d',j,i)).".txt", voigtfv(x)
set print "fit_param.dat" append
print sprintf("%i,%i,%i,%i",a1,a2,w1,w2)
set print
}
I have tried to plot each peaks alone after the plotting of the main fit and plot procedure but is is not working, I dont see the subpeaks only the result of the fitting procedure.

A bit late..., but maybe this is still helpful to you. Although, I don't understand how exactly your function is related to the Voigt profile (maybe an approximation?) and why it has some linear term
y1*x. As I understand the Voigt-profile is a convolution of a Lorentz and a Gaussian distribution.Actually, gnuplot has some Voigt-function implemented: check
help voigt. As much as I understandvoigt(x,0)is a Gauss profile andvoigt(x,1)is a Lorentz profile.Some comments:
set locale "German"andset decimalsign locale. Maybe there are other ways.Undefined value during function evaluation. You also might find a way to get automated estimations, e.g. peak positionsx1,x2are easy, butb1,b2andpmight need more thoughts.voigt(x,p)profile, parameterphas been kept the same for the two peaks.Script:
Result: