Libiap: interactive plotting/fitting using Gnuplot
Libiap is a set of Gnuplot (>=4.2) scripts to provide a simple library to handle mouse input in Gnuplot. So far interactive fitting of a sum of several Lorentzian curves to some data has been implemented. But it can be easily adopted to fit e.g. Gaussians, exponential decay, etc.
Interactive fitting is fitting a set of data by supplying the initial guess values just by clicking on the plot. You also can use libiap for completely different tasks in your own scripts. Just Have a look at the demonstration program of libiap…
Demonstration
Here is a step-by-step introduction of the demonstration program.
Step 0
Download libiap-20080628.zip (2008/06/28, cc-by-nc-sa licence) and extract the *.zip file. Run Gnuplot and type “load demo1.gnuplot”.
Step 1
This screen only displays a superposition of four randomly generated Lorentz peaks. Press “y” on your keyboard if you want to generate a new set of data. Press “n” or just “return” to proceed. Hint: The default answer is always printed in capital letters. “return” accepts this default.
Step 2
To make the fitting procedure more interesting a small amount of noise is added to the actual function. You can see the generated data in “demo1.dat”. Press any key on the keyboard to continue.
Step 3
Select the minimal x value you want to consider for the fit. You could use this feature to suppress peaks you don’t want to be fitted.
Step 4
Now select the maximum x value.
Step 5
Click on the baseline of your spectrum (“offset”).
Step 6
Select the first peak by clicking on its maximum. Actually you’d have to click slightly below, but the fit usually converges anyway.
Step 7
Select the full width at half maximum of your peak. The green line is right in the middle of the baseline and the maximum. So click somewhere on the intersection of the green line and your peak – or where you think the peak should intersect the green line.
Step 8
After selecting the FWHM you’ll be asked if you want to add more peaks. You can do so by pressing the “y” or “return” key. This will repeat step 7 until you have selected all peaks (four in the demonstration).
Step 9
If you have selected all peaks, press “n” in order to start the actual fitting procedure with the guesses you just made.
Step 10
This screen shows your initial guesses again. Should look quite good already.
Step 11
So now here’s the final result – without typing a single number! The fit results are written to “demo1_fit.gnuplot” as a Gnuplot script. You can easily load this file into your post-processing scripts and use all results there without having to fit the data again.
The screenshots have been made with Gnuplot from CVS and the wxWidgets terminal “wxt” (which looks much better than the usual x11 terminal).
Pitfalls
- The demonstration “demo1.gnuplot” needs write access to the current directory, because it stores the sample data in a file called “demo1.dat”. It also generates a file called “demo1_fit.gnuplot” with the fit results.
- Don’t call “gnuplot demo1.gnuplot” directly. This wouldn’t give you an interactive gnuplot shell and close right after the last plot has been displayed.
Known bugs
- No bugs know yet. If you find any please let me know (preferably already with a solution
).
Downloads
- libiap-20080628.zip (2008/06/28, cc-by-nc-sa licence)






September 6th, 2010 at 8:05 pm
Buy:Accutane.Prevacid.Lumigan.Valtrex.Zovirax.Human Growth Hormone.Petcam (Metacam) Oral Suspension.Zyban.Nexium.Actos.100% Pure Okinawan Coral Calcium.Retin-A.Prednisolone.Mega Hoodia.Arimidex.Synthroid….
September 7th, 2010 at 12:02 pm
Buy:Mega Hoodia.Lumigan.100% Pure Okinawan Coral Calcium.Actos.Prednisolone.Retin-A.Arimidex.Nexium.Accutane.Zovirax.Human Growth Hormone.Petcam (Metacam) Oral Suspension.Valtrex.Zyban.Synthroid.Prevacid….