Header Ads

Header ADS

Plotting results using the GNUPLOT software on Linux

Learning GNUPLOT:

To learn how to use GNUPLOT on linux to plot the results check the following links:

http://galileo.phys.virginia.edu/compfac/courses/geek-hours/gnuplot.html

http://lowrank.net/gnuplot/intro/plotfunc-e.html


Exercising GNUPLOT:

1- Create the script

To write a script we need a text editor like emacs or gedit but we prefer the editor kwrite.

If you haven't this editor you can download and install it directly from terminal as follows:

Ubuntu: sudo apt-get install kwrite 

Opensuse: sudo zypper install kwrite

example:

---------------------------------------
#!/usr/bin/gnuplot

reset
set terminal png
set output 'Lor-function.png'
set format y "%.5f"

set xlabel "Energy [MeV]"
set ylabel "Cross Section [b]"
set xtics 0.1
set ytics 0.5


a=0.25
b=0.02
c=0.05
d=0.1

f(x)=c/((x-a)*(x-a)+b)+d/sqrt(x)

set xrange [0:1]
set yrange [0:4]


plot "plotexp-dat" using 1:2:3 title "experiment", f (x)

 ------------------------------------------


2- Execute the Script

* try to give a name to this script: Lorentzian

* go through terminal to the repertory containing the script and run this command of permission: chmod +x Lorentzian

* check if the permission is given: run ls and you will find the colour of the script becomes green.

*  you need the exp.dat file (you can download it from here  http://lowrank.net/gnuplot/intro/plotexp.dat )

* you copy this file in the same directory of the script

* run this command to execute the script: ./Lorentzian

3- Result

 You will get an image with this name:  Lor-function.png



Good Luck

No comments

Powered by Blogger.