# Contents of /trunk/pyvisi/test/python/plplot/contourPlot.py

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: 1434 byte(s)
```example cleanup
```
 1 # \$Id: contourPlot.py,v 1.1 2005/11/08 05:54:01 paultcochrane Exp \$ 2 3 """ 4 Example of contour plotting with pyvisi 5 """ 6 7 # set up some data to plot 8 from Numeric import * 9 10 # the x and y axes 11 x = arange(-2,2,0.2, typecode=Float) 12 y = arange(-2,3,0.2, typecode=Float) 13 14 # pick some interesting function to generate the data in the third dimension 15 # this is the one used in the matlab docs: z = x*exp(-x^2-y^2) 16 z = zeros((len(x),len(y)), typecode=Float) 17 18 # boy do *I* feel old fashioned writing it this way 19 # surely there's another way to do it: - something to do later 20 for i in range(len(x)): 21 for j in range(len(y)): 22 z[i,j] = x[i]*exp(-x[i]*x[i] - y[j]*y[j]) 23 24 import plplot 25 26 # determine the min and max of x 27 xMin = min(x) 28 xMax = max(x) 29 30 yMin = min(y) 31 yMax = max(y) 32 33 plplot.plsdev("xwin") 34 plplot.plinit() 35 plplot.plenv(xMin, xMax, yMin, yMax, 0, 1) 36 plplot.pllab("x", "y", "Example shaded contour plot") 37 plshades(zz, shedge, fill_width, 1, pltr1, xg1, yg1) 38 39 zmin = min(zz.flat) 40 zmax = max(zz.flat) 41 42 clevel = zmin + (zmax - zmin) * (arrayrange(NS)+0.5)/NS 43 shedge = zmin + (zmax - zmin) * (arrayrange(NS+1))/NS 44 45 plplot.plend() 46 47 # to save as well, have to set everything up again, and replot 48 # save as png 49 plplot.plsdev("png") 50 plplot.plsfnam("contourPlot.png") 51 plplot.plinit() 52 plplot.plenv(xMin, xMax, yMin, yMax, 0, 1) 53 plplot.pllab("x", "y", "Example shaded contour plot") 54 plplot.plline(x, y1) 55 plplot.plend() 56 57 # vim: expandtab shiftwidth=4:

 ViewVC Help Powered by ViewVC 1.1.26