from numpy import pi x = np.linspace( 0, 2*pi, 100 ) # useful to evaluate function at lots of points f = np.sin(x) b = np.fromfunction(f,(100,0),dtype=int) y,x = np.ogrid[ -1.4:1.4:h*1j, -2:0.8:w*1j ]