/[escript]/branches/stage3.0/doc/examples/usersguide/poisson_matplotlib.py
ViewVC logotype

Diff of /branches/stage3.0/doc/examples/usersguide/poisson_matplotlib.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2585 by jfenwick, Wed Aug 5 02:44:51 2009 UTC revision 2586 by jfenwick, Wed Aug 5 05:11:58 2009 UTC
# Line 43  try: Line 43  try:
43      # interpolate u to a matplotlib grid:      # interpolate u to a matplotlib grid:
44      x_grid = numpy.linspace(0.,1.,50)      x_grid = numpy.linspace(0.,1.,50)
45      y_grid = numpy.linspace(0.,1.,50)      y_grid = numpy.linspace(0.,1.,50)
46      x=mydomain.getX()[0].toListOfTuples()      x=mydomain.getX()[0].toListOfTuples(scalarastuple=False)
47      y=mydomain.getX()[1].toListOfTuples()      y=mydomain.getX()[1].toListOfTuples(scalarastuple=False)
48      z=interpolate(u,mydomain.getX().getFunctionSpace()).toListOfTuples()      z=interpolate(u,mydomain.getX().getFunctionSpace()).toListOfTuples(scalarastuple=False)
49      z_grid = matplotlib.mlab.griddata(x,y,z,xi=x_grid,yi=y_grid )      z_grid = matplotlib.mlab.griddata(x,y,z,xi=x_grid,yi=y_grid )
50      # interpolate u to a rectangular grid:      # interpolate u to a rectangular grid:
51      matplotlib.pyplot.contourf(x_grid, y_grid, z_grid, 5)      matplotlib.pyplot.contourf(x_grid, y_grid, z_grid, 5)
52      matplotlib.pyplot.savefig("u.png")      matplotlib.pyplot.savefig("u.png")
53      # uncommend this line if you want to interact with a plot window      # uncomment this line if you want to interact with a plot window
54      matplotlib.pyplot.show()      #matplotlib.pyplot.show()
55    
56  except AttributeError:  except AttributeError:
57      print "Your version of matplotlib does not provide the griddata method.\nSkipping example.\n"      print "Your version of matplotlib does not provide the griddata method.\nSkipping example.\n"

Legend:
Removed from v.2585  
changed lines
  Added in v.2586

  ViewVC Help
Powered by ViewVC 1.1.26