Saturday, April 23, 2011

Plot graphs: gnuplot

I am doing my final year project on network simulator. I had to plot my results in Ubuntu. I found "Gnuplot"; a free, command-driven, interactive, function and data plotting program. We can easily plot graphs of common functions like sine, cosine, sinc, and many more. We can also plot the tabulated data. Gnuplot on my terminal looks like as shown below.
figure: terminal window

Interesting feature about this program is that you don't have to define x-range, x-scale and y-scale. Just type "sin(x)" and you have plotted graph of sin(x). The ranges are suitably defined unlike Matlab, and other languages where you have to define x range from 0 to pi or something like that. I have plotted sin(x) and sin(x)/x as shown in figure below.

figure: plot of sine function
 figure: plot of sinc function

Important commands:
Create a title:                    > set title "title"
Put a label on the x-axis:   > set xlabel "xlabel"
Put a label on the y-axis:   > set ylabel "ylabel"
Change the x-axis range:   > set xrange [x1:x2]
Change the y-axis range:   > set yrange [y1:y2]
For notes and documentation, click here.

No comments:

Post a Comment

Visualization of Electromagnetic wave in MATLAB

Wave is imaginary and mysterious thing to us. Many of them are invisible and we even don’t know their pres...