[BACK]Return to vector.dem CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / demo

Annotation of OpenXM_contrib/gnuplot/demo/vector.dem, Revision 1.1

1.1     ! maekawa     1: #
        !             2: # This file demonstrates new features in gnuplot 3.6
        !             3: # -1- saving contour lines as a gnuplottable file
        !             4: # -2- plotting a vector field on the same graph
        !             5: # -3- manipulating columns using the '$1,$2' syntax.
        !             6: # the example is taken here from Physics is the display of equipotential
        !             7: # lines and electrostatic field for a dipole (+q,-q)
        !             8: print "\n This file demonstrates new features in gnuplot 3.6"
        !             9: print " -1- saving contour lines as a gnuplottable file"
        !            10: print " -2- plotting a vector field on the same graph"
        !            11: print " -3- manipulating columns using the '$1,$2' syntax."
        !            12: print " the example is taken here from Physics is the display of equipotential"
        !            13: print " lines and electrostatic field for a dipole (+q,-q)"
        !            14: print "\n Please note that this demo runs only on x11 term, because"
        !            15: print " It needs to change term to table and then back to screen,"
        !            16: print " and gnuplot currently has no way of saving current terminal."
        !            17: pause -1 "<CR> to continue"
        !            18: #
        !            19:       r(x,y)=sqrt(x*x+y*y)
        !            20:       v1(x,y)=  q1/(r((x-x0),y))
        !            21:       v2(x,y)=  q2/(r((x+x0),y))
        !            22: #
        !            23:       vtot(x,y)=v1(x,y)+v2(x,y)
        !            24: #
        !            25:       e1x(x,y)= q1*(x-x0)/r(x-x0,y)**3
        !            26:       e1y(x,y)= q1*(y)/r(x-x0,y)**3
        !            27:       e2x(x,y)= q2*(x+x0)/r(x+x0,y)**3
        !            28:       e2y(x,y)= q2*(y)/r(x+x0,y)**3
        !            29:       etotx(x,y)=e1x(x,y)+e2x(x,y)
        !            30:       etoty(x,y)=e1y(x,y)+e2y(x,y)
        !            31:       enorm(x,y)=sqrt(etotx(x,y)*etotx(x,y)+etoty(x,y)*etoty(x,y))
        !            32:       dx1(x,y)=coef*etotx(x,y)/enorm(x,y)
        !            33:       dy1(x,y)=coef*etoty(x,y)/enorm(x,y)
        !            34:       dx2(x,y)=coef*etotx(x,y)
        !            35:       dy2(x,y)=coef*etoty(x,y)
        !            36: #
        !            37:       coef=.7
        !            38:       x0=1.
        !            39:       q1=1
        !            40:       q2=-1
        !            41:       xmin=-10.
        !            42:       xmax=10.
        !            43:       ymin=-10.
        !            44:       ymax=10.
        !            45: #
        !            46: reset
        !            47: set term x11
        !            48: set noautoscale
        !            49: set xr [xmin:xmax]
        !            50: set yr [ymin:ymax]
        !            51: set isosam 31,31
        !            52: set view 0, 0, 1, 1
        !            53: set nosurface
        !            54: set contour base
        !            55: set cntrparam order 4
        !            56: set cntrparam linear
        !            57: set cntrparam levels discrete -3,-2 ,-1 ,-0.5 ,-0.2 ,-0.1 ,-0.05 ,-0.02 ,0 ,0.02 ,0.05 ,0.1 ,0.2 ,0.5 ,1 ,2 ,3
        !            58: set cntrparam points 5
        !            59: #
        !            60: set label "-q" at -1,0 center
        !            61: set label "+q" at  1,0 center
        !            62: splot vtot(x,y) w l
        !            63: pause -1 "Now create a file with equipotential lines <CR> to continue"
        !            64: set term table
        !            65: set out "equipo2.dat"
        !            66: rep
        !            67: set out
        !            68: set term x11
        !            69: reset
        !            70: plot "equipo2.dat" w l
        !            71: pause 0 "Now create a x/y datafile for plotting with vectors "
        !            72: pause 0"and display vectors parallel to the electrostatic field"
        !            73: pause -1 "<CR> to continue"
        !            74: set isosam 31,31
        !            75: set term table
        !            76: set out "field2xy.dat"
        !            77: splot vtot(x,y) w l
        !            78: set out
        !            79: set term x11
        !            80: set noautoscale
        !            81: set xr [xmin:xmax]
        !            82: set yr [ymin:ymax]
        !            83: set isosam 31,31
        !            84: plot "field2xy.dat" u 1:2:(coef*dx1($1,$2)):(coef*dy1($1,$2)) w vec, \
        !            85: "equipo2.dat" w l
        !            86: pause -1 "<CR> to exit"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>