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

Contents of /trunk/pyvisi_old/examples/offsetLinePlot.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 786 - (show annotations)
Tue Jul 25 04:58:05 2006 UTC (13 years, 2 months ago) by gross
File MIME type: text/x-python
File size: 2348 byte(s)
switched off pyvisi
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 @var __author__: name of author
8 @var __license__: licence agreement
9 @var __copyright__: copyrights
10 @var __url__: url entry point on documentation
11 @var __version__: version
12 @var __date__: date of the version
13 """
14
15 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
16 http://www.access.edu.au
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __author__="Paul Cochrane"
21 __url__="http://www.iservo.edu.au/esys"
22 __version__="$Revision$"
23 __date__="$Date$"
24
25
26 import sys
27 numArgs = len(sys.argv)
28 if numArgs == 1:
29 ren_mod = "vtk"
30 else:
31 ren_mod = sys.argv[1]
32
33 # set up some data to plot
34 from Numeric import *
35
36 x = arange(0,2*pi,0.01, typecode=Float)
37 y1 = sin(x)
38 y2 = cos(x)
39 y3 = cos(x)**2
40 y4 = sin(2*x)
41 y5 = cos(3*x)
42 y6 = sin(20*x)
43
44 # example code for how a user would write a script in pyvisi
45 from esys.pyvisi import * # base level visualisation stuff
46 #from esys.pyvisi.utils import * # pyvisi specific utils
47 # import the objects to render the scene using the specific renderer
48 if ren_mod == "gnuplot":
49 from esys.pyvisi.renderers.gnuplot import * # gnuplot
50 elif ren_mod == "vtk":
51 from esys.pyvisi.renderers.vtk import * # vtk
52 elif ren_mod == "plplot":
53 from esys.pyvisi.renderers.plplot import * # plplot
54 else:
55 raise ValueError, "Unknown renderer module"
56
57 # define the scene object
58 # a Scene is a container for all of the kinds of things you want to put
59 # into your plot for instance, images, meshes, arrow/vector/quiver plots,
60 # contour plots, spheres etc.
61 scene = Scene()
62
63 # create a LinePlot object
64 plot = LinePlot(scene)
65
66 # add some helpful info to the plot
67 plot.title = 'Example 2D plot with offsets'
68 plot.xlabel = 'x'
69 plot.ylabel = 'y'
70
71 plot.linestyle = 'lines'
72
73 # assign some data to the plot
74 plot.setData(x, y1, y2, y3, y4, y5, y6, offset=True)
75
76 # render the scene to screen
77 scene.render(pause=True, interactive=True)
78
79 # save the scene to file
80 scene.save(fname="offsetLinePlot.png", format=PngImage())
81
82 # vim: expandtab shiftwidth=4:
83

  ViewVC Help
Powered by ViewVC 1.1.26