/[escript]/trunk/pyvisi/test/python/gnuplot/offsetLinePlot.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/gnuplot/offsetLinePlot.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 604 - (show annotations)
Mon Mar 20 02:23:14 2006 UTC (13 years, 7 months ago) by gross
File MIME type: text/x-python
File size: 1444 byte(s)
example cleanup
1 # $Id: offsetLinePlot.py,v 1.1 2005/11/08 06:48:54 paultcochrane Exp $
2 """
3 Example of plotting multiple curves offset from each other
4
5 This is especially handy for people plotting seismic data
6 """
7
8 # set up some data to plot
9 from Numeric import *
10
11 x = arange(0,2*pi,0.01, typecode=Float)
12 y1 = sin(x)
13 y2 = cos(x)
14 y3 = cos(x)**2
15 y4 = sin(2*x)
16 y5 = cos(3*x)
17 y6 = sin(20*x)
18
19 #### original gnuplot code
20
21 import Gnuplot
22
23 # set the plot up
24 _gnuplot = Gnuplot.Gnuplot()
25 _gnuplot.title('Example 2D plot with offsets')
26 _gnuplot.xlabel('x')
27 _gnuplot.ylabel('y')
28
29 ### set up the data
30 # concatenate the data
31 yAll = concatenate( [y1, y2, y3, y4, y5, y6] )
32
33 yMax = max(yAll)
34 yMin = min(yAll)
35
36 # keep the data apart a bit
37 const = 0.1*(yMax-yMin)
38
39 # don't need to worry about y1: it's the first data series
40 shift = yMax - yMin + const
41 y2 = y2 + shift
42 y3 = y3 + 2*shift
43 y4 = y4 + 3*shift
44 y5 = y5 + 4*shift
45 y6 = y6 + 5*shift
46
47 _data1 = Gnuplot.Data(x, y1, with='lines')
48 _data2 = Gnuplot.Data(x, y2, with='lines')
49 _data3 = Gnuplot.Data(x, y3, with='lines')
50 _data4 = Gnuplot.Data(x, y4, with='lines')
51 _data5 = Gnuplot.Data(x, y5, with='lines')
52 _data6 = Gnuplot.Data(x, y6, with='lines')
53
54 # plot it
55 _gnuplot.plot(_data1, _data2, _data3, _data4, _data5, _data6)
56
57 # save it to file
58 _gnuplot('set terminal png')
59 _gnuplot('set output "offsetLinePlot.png"')
60 _gnuplot.plot(_data1, _data2, _data3)
61
62 raw_input('Press enter to continue...\n')
63
64 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26