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

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

  ViewVC Help
Powered by ViewVC 1.1.26