With this version I've placed the image data and waveforms upon separate figures . Using a few values from the right of the main bulb , there are selections where the z series retains it's magnitude whilst the series for ed tends towards zero. I'm considering another approach to this , which I shall develop for the next version ; meanwhile try exploring. sciwise. """ plot2sz3.py General structure for examining fractal series . Intended for use with Linux type OS's and d1iMandelbrot formula with [x]fractint. (c) copyright 2016 sciwise@ihug.co.nz This version uses separate figures allowing for easier manual selection from the fractal and better discernability of the waveforms. """ # Import libraries import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec # import matplotlib.cbook as cbook import matplotlib.cm as cm # # -------------------------------------------------------------------- # #####Event handler for button_press_event##### def enter_axes(event): print('enter_axes', event.inaxes) event.canvas.draw() def leave_axes(event): print('leave_axes', event.inaxes) event.canvas.draw() def onclick(event): ''' Event handler for button_press_event @param event MouseEvent ''' global ix, iy ix, iy = event.xdata, event.ydata for i, ax in enumerate([ax1, ax2 , ax3]): # For infomation, print which axes the click was in if ax == event.inaxes: # Check if the click was in ax1 if (i+1 == 1 ) : c = pt2c(ix,iy,xTL,yTL,xBR,yBR) d1imand(c) plt.figure(2) ax2.clear() ax2.plot(x2, y2r, 'r.-' ) ax2.plot(x2, y2i, 'b.-') ax3.clear() ax3.plot(x2, yed, 'm.-') plt.draw() plt.figure(1) #print " ",c.real," ",c.imag # Check if the click was in ax1 or ax2 if event.inaxes in [ax1, ax2,ax3]: return iy else: return # # .......................................................................... # # xTL x top left # yTL y top left # xBR x bottom right # yBE y bottom right # def pt2c(ix,iy,xTL,yTL,xBR,yBR): x=xTL+(xBR-xTL)*ix/800 y=yTL+(yBR-yTL)*iy/600 c=complex(x,y) return c def d1imand(c): """ Mandelbrot series = z first derivative = z1 second derivative = z2 Diff' equation = ed = diff(f(z),z) + 3*f(z)*z = sin(z) """ for i in range(n): y2r[i] = 0.0 y2i[i] = 0.0 yed[i] = 0.0 z = c z1 = 1.0 z2 = 0.0 itr=0 ed=0 while ( itr < n) and (abs(z2) < 1000000) and ( abs(z) > 0 ): z2 =2*z1*z1 +2*z2*z z1 = 2*z*z1 + 1 u = z z = z*z+c ed = 3*z*c + z1 - np.sin(u) y2r[itr] = z.real y2i[itr] = z.imag yed[itr] = abs(ed) itr = itr+1 for i in range(200): y2r[i] = 0.0 y2i[i] = 0.0 yed[i] = 0.0 return def fracCorners(file1) : f = open(file1, 'r') x = f.read() j=0 k=0 l=0 for i in range(0,len(x)-8): ns = x[i : i+8] if ( ns=='corners=' ) : l=int(l+8) break l=int(l+1) j=l for i in range(l,len(x)-1): ns = x[i : i+1] if ( ns== "/" ) : break j=int(j+1) s=x[l:j] xTL = np.float64(s) l=j+1 j=l for i in range(l,len(x)-1): ns = x[i : i+1] if ( ns== "/" ) : break j=int(j+1) s = x[l:j] xBR = np.float64(s) l=j+1 j=l for i in range(l,len(x)-1): ns = x[i : i+1] if ( ns== "/" ) : break j=int(j+1) s=x[l:j] yBR = np.float64(s) l=j +1 j=l for i in range(l,len(x)-6): ns = x[i : i+6] if ( ns== "float=" ) : break j=int(j+1) s=x[l:j] yTL = np.float64(s) l=j j=l for i in range(l,len(x)-8): ns = x[i : i+8] if ( ns== "maxiter=" ) : j=j+8 break j=int(j+1) # l=j j=l for i in range(l,len(x)-7): ns = x[i : i+7] if ( ns== "inside=" ) : break j=int(j+1) s = x[l:j] maxiter = np.int64(s) f.close() return [xTL,yTL,xBR,yBR,maxiter] # # --------------------------- Main ----------------------------------------- # # fractint gif file and associated par file. # filegif = 'fract008.gif' filepar = 'fract.par' # # ........................................................................... # fbase = '/usr/share/xfractint/pars/' file1= fbase + filepar xyc=fracCorners(file1) xTL = xyc[0] yTL = xyc[1] xBR =xyc[2] yBR =xyc[3] maxiter=xyc[4] # fbase = '/root/' file2= fbase + filegif imageFile = cbook.get_sample_data(file2) image = plt.imread(imageFile) # # --------------------------------------------------------------------------- # # Generate data # n=maxiter x2 = np.array((np.linspace(0,n,n))) y2r = np.array((np.linspace(0,n,n))) y2i = np.array((np.linspace(0,n,n))) yed = np.array((np.linspace(0,n,n))) # # initial value for c , this to be selected from image . # c=-0.25 + 0.3j #c=-0.47 + 0.018j #c=-0.75 + 0.0014j #c=-0.0099 + 0.005j #c=-0.108516194675302 + 0.9013927770462271j #c=-0.123991033848631 + 0.7429343365256118j # # # ........................................................................... # d1imand(c) # # ------------------------------------------------------------------- # # Plot on seperate figures fig1 = plt.figure() # large subplot ax1=fig1.add_subplot(1,1,1) plt.axis('off') plt.imshow(image, interpolation="none" ) fig1.tight_layout() fig2 = plt.figure() ax2=fig2.add_subplot(2,1,1) plt.plot(x2, y2r, 'r.-') plt.plot(x2, y2i, 'b.-') ax3=fig2.add_subplot(2,1,2) plt.plot(x2, yed, 'm.-') plt.ylabel('Magnitude') fig2.tight_layout() # # cid = fig1.canvas.mpl_connect('button_press_event', onclick) #fig.canvas.mpl_disconnect(cid) plt.show() exit(0) # # -------------------------------------------------------------------- # #fig.set_size_inches(w=11,h=7) #fig_name = 'plot.png' #fig.savefig(fig_name)