/[escript]/trunk/pyvisi/examples/scatterPlot.py
ViewVC logotype

Contents of /trunk/pyvisi/examples/scatterPlot.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 605 - (show annotations)
Mon Mar 20 07:16:27 2006 UTC (13 years, 7 months ago) by gross
File MIME type: text/x-python
File size: 1615 byte(s)
pyvisi with vtk runs noe on the altix
1 # $Id: scatterPlot.py,v 1.3 2005/11/08 08:23:45 paultcochrane Exp $
2
3 """
4 Example of a scatter plot in pyvisi
5 """
6
7 import sys
8 numArgs = len(sys.argv)
9 if numArgs == 1:
10 ren_mod = "gnuplot"
11 else:
12 ren_mod = sys.argv[1]
13
14 # set up some data to plot
15 from Numeric import *
16 import random
17
18 x = arange(30, typecode=Float)
19 y = arange(30, typecode=Float)
20
21 # make the data a bit more scatter-like by using random numbers
22 random.seed()
23 for i in range(len(x)):
24 x[i] = random.random()
25 y[i] = random.random()
26
27 # example code for how a user would write a script in pyvisi
28 from esys.pyvisi import * # base level visualisation stuff
29 #from esys.pyvisi.utils import * # pyvisi specific utils
30 # import the objects to render the scene using the specific renderer
31 if ren_mod == "gnuplot":
32 from esys.pyvisi.renderers.gnuplot import * # gnuplot
33 elif ren_mod == "vtk":
34 from esys.pyvisi.renderers.vtk import * # vtk
35 else:
36 raise ValueError, "Unknown renderer module"
37
38 # define the scene object
39 # a Scene is a container for all of the kinds of things you want to put
40 # into your plot for instance, images, meshes, arrow/vector/quiver plots,
41 # contour plots, spheres etc.
42 scene = Scene()
43
44 # create a ScatterPlot object
45 plot = ScatterPlot(scene)
46
47 # add some helpful info to the plot
48 plot.title = 'Example 2D scatter plot'
49 plot.xlabel = 'x'
50 plot.ylabel = 'y'
51
52 # assign some data to the plot
53 plot.setData(x, y)
54
55 # render the scene to screen
56 scene.render(pause=True, interactive=True)
57
58 # save the scene out to file
59 scene.save(fname="scatterPlot.png", format=PngImage())
60
61 # vim: expandtab shiftwidth=4:
62

  ViewVC Help
Powered by ViewVC 1.1.26