/[escript]/trunk/pyvisi/test/python/gnuplot/arrowPlot.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/gnuplot/arrowPlot.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 604 - (show annotations)
Mon Mar 20 02:23:14 2006 UTC (13 years, 7 months ago) by gross
File MIME type: text/x-python
File size: 1139 byte(s)
example cleanup
1 # $Id: arrowPlot.py,v 1.1 2005/05/05 01:56:51 paultcochrane Exp $
2
3 """
4 Example of plotting a vector field with pyvisi
5 """
6
7 # set up some data to plot
8 from Numeric import *
9
10 # the positions of the vectors
11 x = arange(10, typecode=Float)
12 y = arange(10, typecode=Float)
13
14 # the vector displacements
15 # (I may need to rethink how this works in the interface)
16 dx = arange(10, typecode=Float)
17 dy = arange(10, typecode=Float)
18
19 # set the positions randomly, and set the displacements to be the square of
20 # the positions
21 import random
22 random.seed()
23 for i in range(len(x)):
24 x[i] = random.random()
25 y[i] = random.random()
26 dx[i] = x[i]*x[i]
27 dy[i] = y[i]*y[i]
28
29 #### original gnuplot code
30
31 import Gnuplot
32
33 # set the plot up
34 _gnuplot = Gnuplot.Gnuplot()
35 _gnuplot.title('Example 2D arrow/quiver/vector field plot')
36 _gnuplot.xlabel('x')
37 _gnuplot.ylabel('y')
38
39 # set up the data
40 _data = Gnuplot.Data(x, y, dx, dy, with='vector')
41
42 # plot it
43 _gnuplot.plot(_data)
44
45 # set up to save to file
46 _gnuplot('set terminal png')
47 _gnuplot('set output \"arrowPlotExample.png\"')
48
49 # save it
50 _gnuplot.plot(_data)
51
52 raw_input('Press enter to continue...\n')
53
54

  ViewVC Help
Powered by ViewVC 1.1.26