# ######################################################################## # Trace un ensemble de Julia pixel par pixel dans une fenêtre Matplotlib # # Programme réalisé le 02 novembre 2022 par Jean-Christophe MICHEL # # www.gecif.net # # ######################################################################## import matplotlib.pyplot as plt import math # ensemble de Julia complet : x_min=-1.55974934894274 x_max=1.73429361977433 y_min=-1.23556315104494 y_max=1.23496907549286 # résolution de l'image : res_x=640 res_y=480 # calcul du nombre d'itérations en fonction du grossissement : grossissement=4/(x_max-x_min) iter_max=int((math.log10(grossissement)/12)*10000+200) tab = [] pour_cent=0 print("Grossissement : %g" % grossissement) print("Nombre d'itérations :",iter_max) print("Progression du calcul de l'image :") for py in range(1,res_y+1): ligne=[] if py % (res_y//10)==0: pour_cent+=10 print("%d %% calculé ..." % pour_cent) for px in range(1,res_x+1): n=0 x=x_min+px*(x_max-x_min)/res_x y=y_max-py*(y_max-y_min)/res_y z=complex(x,y) # #################################################################### # L'ensemble de Julia dépend de la valeur du nombre complexe z2 : # #################################################################### #z2=complex(-0.0986,-0.65186) #z2=complex(0.32,0.043) z2=complex(-0.772691322542185,0.124281466072787) #z2=complex(-4.05253601070165E-0001,-6.44628651946028E-0001) #z2=complex(-8.60671234122251E-0001,2.66206614158146E-0001) #z2=complex(3.77390034989716E-0001,1.04280344628515E-0001) #z2=complex(1.98028564451152E-0002,6.71022287982223E-0001) #z2=complex(-3.07991027828944E-0002,6.98009999570495E-0001) #z2=complex(2.99800364173435E-0001,2.33172098636993E-0002) #z2=complex(2.93053436276367E-0001,-2.97037776038500E-0004) # #################################################################### while(abs(z)<2): z=z*z+z2 n+=1 if n>=iter_max: break ligne.append(n) tab.append(ligne) # crée une figure dans la fenêtre et un axe dans la figure : fig=plt.figure(1, figsize=(6.4, 4.8)) ax=fig.add_subplot(1,1,1) # n'affiche pas les graduations sur les axes : ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) # agrandi le repère à toute la surface de la figure : plt.gcf().subplots_adjust(left = 0, bottom = 0, right = 1, top = 1, wspace = 0, hspace = 0) # affiche l'image : ax.imshow(tab, cmap='RdBu', interpolation='none') plt.show()