Pyton 3 code ############################################################ # Newton's method valley landscape generation as a whole # (Matplotlib Mesh plot) ############################################################ import matplotlib.pyplot as plt # import matplotlib modules from mpl_toolkits.mplot3d import Axes3D import matplotlib.figure as fg from matplotlib import cm # import color maps module import numpy as np # import numpy module fig = plt.figure() # set 3D figure environment ax = fig.add_subplot(111, projection='3d') ax.view_init(azim=-140,elev=45) # set view orientation ax.dist = 3.0 # set viewpoint distance ax.set_facecolor([1.0,.6,.15]) # set ground color n = 8 # set number of cycles dx = 0.0 # set initial x parameter shift dy = 0.0 # set initial y parameter shift L = 1.3 # set square area side M = 300 # set side number of pixels def f(Z): # def scale damping of the depth function return np.e**(-np.abs(Z)) x = np.linspace(-L+dx,L+dx,M) # x variable array y = np.linspace(-L+dy,L+dy,M) # y variable array X,Y = np.meshgrid(x,y) # square area grid Z = X + 1j*Y # complex plane area for k in range(1,n+1): # recursion cycle ZZ = Z - (Z**4 + 1)/(4*Z**3) Z = ZZ W = f(Z) ax.set_xlim(dx-L,dx+L) # set x axis limits ax.set_zlim(dy-L,dy+L) # set y axis limits ax.set_zlim(-3.5*L,4*L) # set z axis limits ax.axis("off") # do not plot axes ax.plot_surface(X, Y, W, rstride=1, cstride=1, cmap='flag') # plot surface as a whole plt.show() # show plot