Difference between revisions of "Graphics with gnuplot"
(added images) |
m (Correction from 2009-04-04 Vladimir rsf-user e-mail) |
||
Line 24: | Line 24: | ||
Flow('cosxpy.z','cosxpy', | Flow('cosxpy.z','cosxpy', | ||
''' | ''' | ||
− | disfil number=n col=%d | + | disfil number=n col=%d |
''' % n2) | ''' % n2) | ||
Revision as of 16:19, 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')
- Prepare data for Gnuplot
Flow('cosxpy.z','cosxpy',
disfil number=n col=%d % n2)
- 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