Graphics with gnuplot

From Madagascar
Revision as of 23:52, 23 June 2009 by 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...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 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:

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

To be continued with content from 2009-04-04 rsf-user message from Vladimir