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

Contents of /trunk/pyvisi/examples/simpleLinePlot.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: 1471 byte(s)
pyvisi with vtk runs noe on the altix
1 # $Id: simpleLinePlot.py,v 1.3 2005/11/08 08:23:45 paultcochrane Exp $
2
3 """
4 Example of plotting lines with pyvisi
5 """
6
7 import sys
8 numArgs = len(sys.argv)
9 if numArgs == 1:
10 ren_mod = "vtk"
11 else:
12 ren_mod = sys.argv[1]
13
14 # set up some data to plot
15 from Numeric import *
16
17 x = arange(10, typecode=Float)
18 y = x**2
19
20 # example code for how a user would write a script in pyvisi
21 from esys.pyvisi import * # base level visualisation stuff
22 # import the objects to render the scene using the specific renderer
23 if ren_mod == "gnuplot":
24 from esys.pyvisi.renderers.gnuplot import * # gnuplot
25 elif ren_mod == "vtk":
26 from esys.pyvisi.renderers.vtk import * # vtk
27 elif ren_mod == "plplot":
28 from esys.pyvisi.renderers.plplot import * # plplot
29 else:
30 raise ValueError, "Unknown renderer module"
31
32 # define the scene object
33 # a Scene is a container for all of the kinds of things you want to put
34 # into your plot for instance, images, meshes, arrow/vector/quiver plots,
35 # contour plots, spheres etc.
36 scene = Scene()
37
38 # create a LinePlot object
39 plot = LinePlot(scene)
40
41 # add some helpful info to the plot
42 plot.title = 'Example 2D line plot'
43 plot.xlabel = 'x'
44 plot.ylabel = 'x^2'
45
46 plot.linestyle = 'lines'
47
48 # assign some data to the plot
49 plot.setData(x, y)
50
51 # render the scene to screen
52 scene.render(pause=True, interactive=True)
53
54 # save the scene out to file
55 scene.save(fname="simpleLinePlot.png", format=PngImage())
56
57 # vim: expandtab shiftwidth=4:
58

  ViewVC Help
Powered by ViewVC 1.1.26