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

Annotation of /trunk/pyvisi/examples/offsetPlotExample.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (hide annotations)
Mon Dec 12 01:57:07 2005 UTC (14 years, 6 months ago) by cochrane
File MIME type: text/x-python
File size: 1943 byte(s)
Initial merge of pyvisi into esys repository.
1 cochrane 337 # $Id: offsetPlotExample.py,v 1.4 2005/05/24 01:37:50 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     # set up some data to plot
10     from Numeric import *
11    
12     # read in the data (being fortunate we know how much data there is)
13     fp = open('waves.dat')
14     t = zeros((100), typecode=Float)
15     x = zeros((13), typecode=Float)
16     data = zeros((100,13), typecode=Float)
17     for i in range(100):
18     for j in range(13):
19     line = fp.readline()
20     arr = line.split()
21     t[i] = float(arr[0])
22     x[j] = float(arr[1])
23     data[i,j] = float(arr[2])
24     fp.close()
25    
26     # example code for how a user would write a script in pyvisi
27     from pyvisi import * # base level visualisation stuff
28     #from pyvisi.utils import * # pyvisi specific utils
29     # import the objects to render the scene using the specific renderer
30     #from pyvisi.renderers.gnuplot import * # gnuplot
31     from pyvisi.renderers.vtk import * # vtk
32    
33     # define the scene object
34     # a Scene is a container for all of the kinds of things you want to put
35     # into your plot for instance, images, meshes, arrow/vector/quiver plots,
36     # contour plots, spheres etc.
37     scene = Scene()
38    
39     # create an OffsetPlot object
40     plot = OffsetPlot(scene)
41    
42     # add some helpful info to the plot
43     plot.title = 'OffsetPlot example - waves.dat'
44     plot.xlabel = 't'
45     plot.ylabel = 'y'
46    
47     # assign some data to the plot
48     plot.setData(t, data)
49    
50     # render the scene to screen
51     scene.render(pause=True, interactive=True)
52    
53     # save the scene to file
54     # save as png
55     plot.setData(t, data)
56     # have to do this now because we've already
57     # render()ed the scene. This requirement
58     # will be removed in the future.
59     scene.save(fname="offsetPlotExample.png", format=PngImage())
60    
61     # vim: expandtab shiftwidth=4:
62    

  ViewVC Help
Powered by ViewVC 1.1.26