Gnuplot

From NA-Wiki

(Difference between revisions)
Jump to: navigation, search
 
(8 intermediate revisions not shown)
Line 1: Line 1:
 +
== 1D Data ==
-
== Gnuplot ==
+
Gnuplot makes it very easy to produce nice looking eps plots from the numerical output of your simulation. A good starting point is the following snippet. Either type it in on the gnuplot prompt, or save it in a file and run it with <tt>gnuplot file.p</tt>.
-
Gnuplot makes it very easy to produce nice looking eps plots from the numerical output of your simulation.
+
<pre>
 +
set terminal postscript enhanced color size 5,4 "Helvetica,10"
 +
set out "test.eps"
 +
set pointsize 2
 +
set border linewidth 0.5
 +
unset key
 +
set title "Some plot"
 +
set xlabel "{/Symbol s}"
 +
set ylabel "field"
 +
plot "data1d.txt" with points, \
 +
    "data1d.txt" smooth csplines with lines
 +
</pre>
 +
 
 +
This reads the data in <tt>data1d.txt</tt> and plots it to <tt>test.eps</tt>. The size is set to 5x4 inches.
 +
 
 +
[[Image:plot1.png]]
 +
 
 +
 
 +
== 2D Data ==
 +
2D data is plotted using the splot command:
 +
<pre>
 +
set terminal postscript enhanced color size 5,4 "Helvetica,10"
 +
set out "test2.eps"
 +
set pm3d map
 +
set palette rgbformulae 22,13,-31
 +
set border linewidth 0.5
 +
set title "Reflected pulse"
 +
set xlabel "x"
 +
set ylabel "y"
 +
unset key
 +
splot 'data2d.txt' matrix
 +
</pre>
 +
 
 +
Note here that the option <tt>matrix</tt> to the <tt>splot</tt> command is used when the data is in matrix form. The default data format is three numbers <x y z> per line.
 +
 
 +
[[Image:plot2.png]]

Latest revision as of 08:45, 2 June 2008

1D Data

Gnuplot makes it very easy to produce nice looking eps plots from the numerical output of your simulation. A good starting point is the following snippet. Either type it in on the gnuplot prompt, or save it in a file and run it with gnuplot file.p.

set terminal postscript enhanced color size 5,4 "Helvetica,10"
set out "test.eps"
set pointsize 2
set border linewidth 0.5
unset key
set title "Some plot"
set xlabel "{/Symbol s}"
set ylabel "field"
plot "data1d.txt" with points, \
     "data1d.txt" smooth csplines with lines

This reads the data in data1d.txt and plots it to test.eps. The size is set to 5x4 inches.

Image:plot1.png


2D Data

2D data is plotted using the splot command:

set terminal postscript enhanced color size 5,4 "Helvetica,10"
set out "test2.eps"
set pm3d map
set palette rgbformulae 22,13,-31
set border linewidth 0.5
set title "Reflected pulse"
set xlabel "x"
set ylabel "y"
unset key
splot 'data2d.txt' matrix

Note here that the option matrix to the splot command is used when the data is in matrix form. The default data format is three numbers <x y z> per line.

Image:plot2.png

Personal tools