graph plotting with gnuplot
Gnuplot is a free, command-driven, interactive, function and data plotting program.
Here i’ m providing a quick reference guide for plotting graphs (as many of us don’t bother to go in detailed documentation).
On Unix/Linux systems start Gnuplot by simply typing:
gnuplot
first the formal syntax :
{[function] | {”[datafile]” {datafile-modifiers}}}
{axes [axes] } { [title-spec] } {with [style] }
{, {definitions,} [function] …} To plot functions simply type: plot [function] at the gnuplot> prompt
gnuplot> plot sin(x)
gnuplot> splot sin(x*y/20)
gnuplot> plot sin(x) title ‘Sine Function’, tan(x) title ‘Tangent’
Now for plotting data points firstly data points should be written in text file with axis ranges as columns.Data files should have the data arranged in columns of numbers. Columns should be separated by white space (tabs or spaces) only, (no commas). Lines beginning with a # character are treated as comments and are ignored by Gnuplot. A blank line in the data file results in a break in the line connecting data points. ‘
Plotting a graph from data file “plot.data” , do
gnuplot>plot “plot.data”
Now customizing the plot :
| set xlabel “x-axis data” | # will set a label “x-axis data” in graph | |
| set ylabel “y-axis data” | ||
| set title “x vs y” | # will set title for graph | |
| set xrange [0.001:0.005] | # Change the x-axis range: | |
| set yrange [20:500] | # Change the y-axis range: | |
| set logscale | # plot using log scale | |
| set autoscale | #let gnuplot determine ranges | |
| plot “file.data” with lines | #will join data points with lines | |
| plot “file.data” smooth csplines with lines | #will join plot graph using smooth curves |
to plot sin( col.3 + col.1 ) vs. 3 * col.2 type:
plot ‘force.dat’ using (3*$2):(sin($3+$1))
To print graph (this will store graph in post script(.ps) file do this before plotting graph:
set output “graphs.ps”
set terminal postscript
plot “file.data” using lines
This will save the graph in graph.ps
For more help type ‘help’ in gnuplot mode :
gnuplot>help
somelinks
www.duke.edu/~hpgavin/gnuplot.html
A simple guide to GNU plot
Introduction to GNU plot
Comments
One Response to “graph plotting with gnuplot”
Leave a Reply
Add to del.icio.us Network
Google Reader Shared Items
Twitter Feed
Flickr Photos
Thanks for the post on Gnuplot! It was quick and easy