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

Annotation of /trunk/pyvisi/examples/singleArrayLinePlot.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 605 - (hide annotations)
Mon Mar 20 07:16:27 2006 UTC (14 years, 3 months ago) by gross
File MIME type: text/x-python
File size: 1510 byte(s)
pyvisi with vtk runs noe on the altix
1 cochrane 337 # $Id: singleArrayLinePlot.py,v 1.3 2005/11/08 08:23:45 paultcochrane Exp $
2    
3     """
4     Example of plotting a curve using only one input array 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(0,2*pi,0.1, typecode=Float)
18     y = sin(x)
19    
20     # example code for how a user would write a script in pyvisi
21 gross 605 from esys.pyvisi import * # base level visualisation stuff
22 cochrane 337 # import the objects to render the scene using the specific renderer
23     if ren_mod == "gnuplot":
24 gross 605 from esys.pyvisi.renderers.gnuplot import * # gnuplot
25 cochrane 337 elif ren_mod == "vtk":
26 gross 605 from esys.pyvisi.renderers.vtk import * # vtk
27 cochrane 337 elif ren_mod == "plplot":
28 gross 605 from esys.pyvisi.renderers.plplot import * # plplot
29 cochrane 337 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 plot'
43     plot.xlabel = 'index'
44     plot.ylabel = 'y'
45    
46     plot.linestyle = 'lines'
47    
48     # assign some data to the plot
49     plot.setData(y)
50    
51     # render the scene to screen
52     scene.render(pause=True, interactive=True)
53    
54     # save the scene to file
55     scene.save(fname="singleArrayLinePlot.png", format=PngImage())
56    
57     # vim: expandtab shiftwidth=4:
58    

  ViewVC Help
Powered by ViewVC 1.1.26