Graphics with gnuplot: Difference between revisions

From Madagascar
Jump to navigation Jump to search
Nick (talk | contribs)
New page: [http://www.gnuplot.info/ Gnuplot] is included by default in the vast majority of Linux distributions and is also more flexible in certain ways than GLE. Example SConstruct: <python> from...
 
Nick (talk | contribs)
inserted gnuplot scripts
Line 2: Line 2:
than GLE.
than GLE.


Example SConstruct:
Example SConstruct, that follows the one in the [[Graphics with GLE | GLE example]]:
<python>
<python>
from rsfproj import *
from rsfproj import *
Line 35: Line 35:
End()
End()
</python>
</python>
On some systems, the actual executable is not gnuplot, but gnuplot-minimal. Another dependency is the epstopdf utility, which is a part of LaTeX installation, usually. Gnuplot scripts can render the isometric view in slightly different ways:
On some systems, the actual executable is not gnuplot, but gnuplot-minimal. Another dependency is the epstopdf utility, which is a part of LaTeX installation, usually. Gnuplot scripts can render the isometric view in slightly different ways. Three examples of Gnuplot scripts, and the images produced by each, follow:


'''cosxpy_bsurf.gp''':
'''cosxpy_bsurf.gp''':
Line 57: Line 57:
</pre>
</pre>


To be continued with content from 2009-04-04 rsf-user message from Vladimir
'''cosxpy_cont.gp''':
<pre>
set terminal postscript eps enhanced color
set output
 
set title "Hat function (3D)"
set xtics ("-2" 0, "-1" 10, "0" 20, "1" 30, "2" 40) out
set ytics ("-2" 0, "-1" 10, "0" 20, "1" 30, "2" 40) out
set ztics out
set zrange [-1.5:1.5]
set ztics 0.5
set xlabel "X-axis"
set ylabel "Y-axis"
set zlabel "Z-axis" offset 3,-1
set ticslevel 0.5
set cntrparam levels auto 12
set contour base
set hidden3d offset 0
splot "cosxpy.z" matrix with lines notitle
</pre>
 
'''cosxpy_surf.gp''':
<pre>
set terminal postscript eps enhanced color
set output
 
set title "Hat function (3D)"
set xtics ("-2" 0, "-1" 10, "0" 20, "1" 30, "2" 40) out
set ytics ("-2" 0, "-1" 10, "0" 20, "1" 30, "2" 40) out
set ztics out
set zrange [-1.5:1.5]
set ztics 0.5
set xlabel "X-axis"
set ylabel "Y-axis"
set zlabel "Z-axis" offset 3,-1
set ticslevel 0.5
set palette defined (-1 "blue", 0 "white", 1 "red")
set pm3d at bs
splot "cosxpy.z" matrix with pm3d notitle
</pre>

Revision as of 23:06, 25 June 2009

Gnuplot is included by default in the vast majority of Linux distributions and is also more flexible in certain ways than GLE.

Example SConstruct, that follows the one in the GLE example: <python> from rsfproj import *

o1=-2 o2=-2 n1=41 n2=41 d1=0.1 d2=0.1

Flow('cosxpy',None,

   
   math o1=%g o2=%g n1=%d n2=%d d1=%g d2=%g
         output="cos(x1*x1+x2*x2)*exp(-0.1*(x1*x1+x2*x2))"
    % (o1,o2,n1,n2,d1,d2))

Result('cosxpy','grey color=j')

  1. Prepare data for Gnuplot

Flow('cosxpy.z','cosxpy',

   
   disfil number=n col=%d | /bin/cat
    % n2)
  1. Draw surfaces

Result('cosxpy_iso','cosxpy_bsurf.gp cosxpy.z',

     
     gnuplot | epstopdf --filter
     ,suffix='.pdf')

End() </python> On some systems, the actual executable is not gnuplot, but gnuplot-minimal. Another dependency is the epstopdf utility, which is a part of LaTeX installation, usually. Gnuplot scripts can render the isometric view in slightly different ways. Three examples of Gnuplot scripts, and the images produced by each, follow:

cosxpy_bsurf.gp:

set terminal postscript eps enhanced color
set output

set title "Hat function (3D)"
set xtics ("-2" 0, "-1" 10, "0" 20, "1" 30, "2" 40) out
set ytics ("-2" 0, "-1" 10, "0" 20, "1" 30, "2" 40) out
set ztics out
set zrange [-1.5:1.5]
set ztics 0.5
set xlabel "X-axis"
set ylabel "Y-axis"
set zlabel "Z-axis" offset 3,-1
set ticslevel 0.5
set palette defined (-1 "blue", 0 "white", 1 "red")
set pm3d at b
splot "cosxpy.z" matrix with lines notitle

cosxpy_cont.gp:

set terminal postscript eps enhanced color
set output

set title "Hat function (3D)"
set xtics ("-2" 0, "-1" 10, "0" 20, "1" 30, "2" 40) out
set ytics ("-2" 0, "-1" 10, "0" 20, "1" 30, "2" 40) out
set ztics out
set zrange [-1.5:1.5]
set ztics 0.5
set xlabel "X-axis"
set ylabel "Y-axis"
set zlabel "Z-axis" offset 3,-1
set ticslevel 0.5
set cntrparam levels auto 12
set contour base
set hidden3d offset 0
splot "cosxpy.z" matrix with lines notitle

cosxpy_surf.gp:

set terminal postscript eps enhanced color
set output

set title "Hat function (3D)"
set xtics ("-2" 0, "-1" 10, "0" 20, "1" 30, "2" 40) out
set ytics ("-2" 0, "-1" 10, "0" 20, "1" 30, "2" 40) out
set ztics out
set zrange [-1.5:1.5]
set ztics 0.5
set xlabel "X-axis"
set ylabel "Y-axis"
set zlabel "Z-axis" offset 3,-1
set ticslevel 0.5
set palette defined (-1 "blue", 0 "white", 1 "red")
set pm3d at bs
splot "cosxpy.z" matrix with pm3d notitle