2 # import matplotlib.pyplot as plt
4 # from topng import affine
7 from numpy import exp,arange
8 from pylab import meshgrid,cm,imshow,contour,clabel,colorbar,axis,title,show
10 # the function that I'm going to plot
12 return (1-(x**2+y**3))*exp(-(x**2+y**2)/2)
14 x = arange(-3.0,3.0,0.1)
15 y = arange(-3.0,3.0,0.1)
16 X,Y = meshgrid(x, y) # grid of point
17 Z = z_func(X, Y) # evaluation of the function on the grid
19 im = imshow(Z,cmap=cm.RdBu) # drawing the function
20 # adding the Contour lines with labels
21 cset = contour(Z,arange(-1,1.5,0.2),linewidths=2,cmap=cm.Set2)
22 clabel(cset,inline=True,fmt='%1.1f',fontsize=10)
23 colorbar(im) # adding the colobar on the right
25 title('$z=(1-x^2+y^3) e^{-(x^2+y^2)/2}$')
29 # dep = ( 0, pow(2, 8) ) # 9 bits
30 # arr = ( 0, pow(2, 16) ) # 16 bits
32 # deprange = np.arange(0, pow(2, 8), 1) # 9 bits
36 # # plt.plot(dep, arr, 'r--', deprange, deprange<<8, 'bs')
40 # # for i in deprange:
41 # # print( 'i, i<<8:', (i, i<<8) )
45 # print("affine transfo")
54 # r = max( 0, ( (i-a) * (d-c) / (b-a) + c ) )
56 # print( 'i, r:', (i, r) )
57 # print( 'i, i<<8:', (i, r2) )
60 # print('count', count)