Difference between revisions of "NumericPython"
Jump to navigation
Jump to search
| Line 15: | Line 15: | ||
<pre> | <pre> | ||
| − | + | x = arange(-5,10) | |
| − | + | y = arange(-4,11) | |
| + | z1 = sqrt(add.outer(x**2,y**2)) | ||
| + | Z = sin(z1)/z1 | ||
</pre> | </pre> | ||
| − | + | If you have the '''NumTut''' package available, then you can simply type: | |
| + | |||
| + | <pre> | ||
| + | from NumTut import * | ||
| + | view(Z) | ||
| + | </pre> | ||
| + | |||
| + | Otherwise, we can use the '''matplotlib''' package: | ||
| + | |||
| + | <pre> | ||
| + | import matplotlib.pyplot as plt | ||
| + | X, Y = meshgrid(x,y) | ||
| + | plt.figure() | ||
| + | plt.contour(X,Y,Z) | ||
| + | plt.show() | ||
| + | </pre> | ||
Revision as of 14:22, 21 July 2009
Numeric Python: Some handy array tools
Introduction
Getting Started
from Numeric import *
Arrays
More Interesting
x = arange(-5,10) y = arange(-4,11) z1 = sqrt(add.outer(x**2,y**2)) Z = sin(z1)/z1
If you have the NumTut package available, then you can simply type:
from NumTut import * view(Z)
Otherwise, we can use the matplotlib package:
import matplotlib.pyplot as plt X, Y = meshgrid(x,y) plt.figure() plt.contour(X,Y,Z) plt.show()