source: tools/pytools/graphics.py @ 36

Last change on this file since 36 was 18, checked in by ole, 20 years ago

Added old pytools module from CVS

File size: 740 bytes
Line 
1###############################
2def plot(f, delay=1):
3  # Plot it
4  #
5  #
6  from Gnuplot import Gnuplot, GridData
7  g = Gnuplot()
8  g('set grid')
9 
10 
11  if len(f.shape) > 2:
12    # Plot a 2D slice from last two dimensions
13   
14    N = len(f.shape)
15    zeros = '0,'*(N-2)
16    s = 'GridData(f[' + zeros + ':,:],with="lines")'
17    data = eval(s)
18    g.splot(data)       
19 
20  else:
21    data = GridData(f,with="lines")
22    g.splot(data)       
23 
24  import types
25  if delay:
26    if type(delay) in [types.IntType, types.FloatType, types.LongType]: 
27      import time 
28      time.sleep(delay)
29    else:
30      raise "Unknown type for delay", delay   
31  else:
32    raw_input('Press any key to stop')
33
34
35     
Note: See TracBrowser for help on using the repository browser.