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

Contents of /trunk/pyvisi/examples/offsetPlot.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: 1901 byte(s)
Initial merge of pyvisi into esys repository.
1 # $Id: offsetPlot.py,v 1.3 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 an example with simulated seismic data, and is a larger dataset
6 than seismicOffsetPlotExample.py
7 """
8
9 import sys
10 numArgs = len(sys.argv)
11 if numArgs == 1:
12 ren_mod = "vtk"
13 else:
14 ren_mod = sys.argv[1]
15
16 # set up some data to plot
17 from Numeric import *
18
19 # read in the data (being fortunate we know how much data there is)
20 fp = open('waves.dat')
21 t = zeros((100), typecode=Float)
22 x = zeros((13), typecode=Float)
23 data = zeros((100,13), typecode=Float)
24 for i in range(100):
25 for j in range(13):
26 line = fp.readline()
27 arr = line.split()
28 t[i] = float(arr[0])
29 x[j] = float(arr[1])
30 data[i,j] = float(arr[2])
31 fp.close()
32
33 # example code for how a user would write a script in pyvisi
34 from pyvisi import * # base level visualisation stuff
35 #from pyvisi.utils import * # pyvisi specific utils
36 # import the objects to render the scene using the specific renderer
37 if ren_mod == "gnuplot":
38 from pyvisi.renderers.gnuplot import * # gnuplot
39 elif ren_mod == "vtk":
40 from pyvisi.renderers.vtk import * # vtk
41 else:
42 raise ValueError, "Unknown renderer module"
43
44 # define the scene object
45 # a Scene is a container for all of the kinds of things you want to put
46 # into your plot for instance, images, meshes, arrow/vector/quiver plots,
47 # contour plots, spheres etc.
48 scene = Scene()
49
50 # create an OffsetPlot object
51 plot = OffsetPlot(scene)
52
53 # add some helpful info to the plot
54 plot.title = 'OffsetPlot example - waves.dat'
55 plot.xlabel = 't'
56 plot.ylabel = 'y'
57
58 # assign some data to the plot
59 plot.setData(t, data)
60
61 # render the scene to screen
62 scene.render(pause=True, interactive=True)
63
64 # save the scene to file
65 scene.save(fname="offsetPlot.png", format=PngImage())
66
67 # vim: expandtab shiftwidth=4:
68

  ViewVC Help
Powered by ViewVC 1.1.26