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

Contents of /trunk/pyvisi/examples/singleArrayPlotExample.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: 1420 byte(s)
Initial merge of pyvisi into esys repository.
1 # $Id: singleArrayPlotExample.py,v 1.12 2005/05/24 01:44:15 paultcochrane Exp $
2
3 """
4 Example of plotting a curve using only one input array with pyvisi
5 """
6
7 # set up some data to plot
8 from Numeric import *
9
10 x = arange(0,2*pi,0.1, typecode=Float)
11 y = sin(x)
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 plot'
31 plot.xlabel = 'index'
32 plot.ylabel = 'y'
33
34 plot.linestyle = 'lines'
35
36 # assign some data to the plot
37 plot.setData(y)
38
39 # render the scene to screen
40 scene.render(pause=True, interactive=True)
41
42 # save the scene to file
43 plot.setData(y) # have to do this now because we've already render()ed
44 # the scene. This requirement will be removed in the
45 # future
46 scene.save(fname="singleArrayLinePlot.png", format=PngImage())
47
48 # vim: expandtab shiftwidth=4:
49

  ViewVC Help
Powered by ViewVC 1.1.26