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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (show annotations)
Mon Dec 12 01:57:07 2005 UTC (13 years, 9 months ago) by cochrane
File MIME type: text/x-python
File size: 1378 byte(s)
Initial merge of pyvisi into esys repository.
1 # $Id: simplePlotExample.py,v 1.9 2005/05/24 01:42:44 paultcochrane Exp $
2
3 """
4 Example of plotting lines with pyvisi
5 """
6
7 # set up some data to plot
8 from Numeric import *
9
10 x = arange(10, typecode=Float)
11 y = x**2
12
13 # example code for how a user would write a script in pyvisi
14 from pyvisi import * # base level visualisation stuff
15 # import the objects to render the scene using the specific renderer
16 #from pyvisi.renderers.gnuplot import * # gnuplot
17 from pyvisi.renderers.vtk import * # vtk
18 #from pyvisi.renderers.plplot import * # plplot
19
20 # define the scene object
21 # a Scene is a container for all of the kinds of things you want to put
22 # into your plot for instance, images, meshes, arrow/vector/quiver plots,
23 # contour plots, spheres etc.
24 scene = Scene()
25
26 # create a LinePlot object
27 plot = LinePlot(scene)
28
29 # add some helpful info to the plot
30 plot.title = 'Example 2D line plot'
31 plot.xlabel = 'x'
32 plot.ylabel = 'x^2'
33
34 plot.linestyle = 'lines'
35
36 # assign some data to the plot
37 plot.setData(x, y)
38
39 # render the scene to screen
40 scene.render(pause=True, interactive=True)
41
42 # save the scene out to file
43 ## png
44 plot.setData(x, y) # have to do this now because we've already
45 # render()ed the scene, will be removed in the
46 # future
47 scene.save(fname="simpleLinePlot.png", format=PngImage())
48
49 # vim: expandtab shiftwidth=4:
50

  ViewVC Help
Powered by ViewVC 1.1.26