This python 2.7 code is intended for use with a Linux type system. The *.gif and *.par files are generated from xfractint and then read and displayed . The mouse is then used to select a pixel value from the image , this is then used to calculate z , z1 , z2 and ed . The real and imaginary components of the z series are then shown as blue and red waveforms. The differential equation results are shown in magenta. The objective is to have the magenta values go to zero whilst the red or blue values remain greater than zero. This may involve going back to fractint and selecting a another region , saving the *.gif and *.par files , then invoking the python code again ; with the new *.gif and *.par files. I use geany to edit and run python files. """ plot2sz2.py General structure for examining fractal series . Intended for use with Linux type OS's and d1iMandelbrot formula with fractint. (c) copyright 2016 sciwise@ihug.co.nz """ # 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]): # 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) ax2.clear() ax2.plot(x2, y2r, 'r.-' ) ax2.plot(x2, y2i, 'b.-') ax2.plot(x2, yed, 'm.-') plt.draw() #print " ",c.real," ",c.imag # Check if the click was in ax1 or ax2 if event.inaxes in [ax1, ax2]: 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 figure with subplots of different sizes fig = plt.figure(1) # set up subplot grid gridspec.GridSpec(6,6) # large subplot ax1 = plt.subplot2grid((6,6), (0,0), colspan=5, rowspan=5) plt.axis('off') plt.imshow(image, interpolation="none" ) # # # small subplot 3 ax2 = plt.subplot2grid((6,6), (5,0), colspan=6, rowspan=1) plt.locator_params(axis='x', nbins=6) plt.locator_params(axis='y', nbins=5) plt.plot(x2, y2r, 'r.-') plt.plot(x2, y2i, 'b.-') plt.plot(x2, yed, 'm.-') plt.ylabel('Magnitude') # fit subplots and save fig fig.tight_layout() cid = fig.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)