In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how python draws cool dynamic Julia sets. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Preface
This Julia is not the other Julia, which refers to the set of complex z z z for a complex c c c such that the iterative formula f (z) = Z2QuC f (z) = z ^ 2 + c f (z) = Z2Crc converges. For example, when cedar 0 cis 0 cv 0, then its convergence interval is z 2.
< 1 z^2m]=0 out[absz>M] = I # record the divergence velocity of the divergence point z = Zhonz + c print ("time:", time.time ()-t) return outz1 = genZ (- 2lemently1.5) mBrot = getJulia (Z1LZ) 50) plt.imshow (mBrot.get (), cmap=plt.cm.jet) plt.show ()
If you are interested in its generation process, you can observe how the image changes as the number of iterations increases.
The code is as follows.
From matplotlib import animationfig = plt.figure () fig.subplots_adjust (top=1, bottom=0, left=0, right=1) ax = plt.subplot () def getJulias Cp.abs (z) c = cp.zeros_like (z) + c J = [] for i in range (n): Z = Zhonz + c absz = cp.abs (z) z [absz > m] = 0 # zero c [absz > m] = 0 out [absz > m] = I # record the divergence velocity of the divergence point Im = ax.imshow (out.get () Cmap=plt.cm.jet, animated=True) ax.set_axis_off () J.append ([im]) return JN = 75 # number of iterations Z1 = genZ (- 2 interval=50 1.5) 1000pc003) J = getJulias (Z1 interval=50, blit=True,repeat_delay=1000 N) ani = animation.ArtistAnimation (fig, J, interval=50, blit=True,repeat_delay=1000) plt.show () ani.save ('julias.gif',writer='imagemagick') infinite scaling
The fractal feature of the Mandelbrot set means that the image we generate can be magnified infinitely, but due to the influence of the rasterized size, manual magnification will not change its true size.
In order to take care of the look and feel, the zoom center is taken as the center of the image, so the genZ function is modified. If (- 0.75) is selected as the zoom center, the change is as follows
The code is
From matplotlib import animation# generates z coordinates xy=np.array ([xc,yc]) as the starting point, and # nxy=np.array ([nx,ny]) as the number of points Delta is the distance from the point def genZbyCenter (xy,nxy,delta): X0Magne y0 = xy-np.array (nxy) * delta/2 return genZ) mBrots = [] xy = [- 0.75 Lindlle 0.2] nxy = [1000L1000] delta0 = 0.003 # initial width fig = plt.figure () fig.subplots_adjust (top=1, bottom=0, left=0, right=1) ax = plt.subplot for n in range (50): Z1 = genZbyCenter (xy,nxy) 1.1 ax.set_axis_off * (- n) * delta0) out = getJulia (Z1Powerz1jing40) im = ax.imshow (out.get (), cmap=plt.cm.jet, animated=True) ax.set_axis_off () mBrots.append ([im]) ani = animation.ArtistAnimation (fig, mBrots, interval=50, blit=True) plt.show () ani.save ('zoom.gif',writer='imagemagick') Julia set
If you change the value of c, you will get a changing Julia set, for example, select a straight line below
Yellowx yellowx yellowx
The above Julia set has the effect shown in the figure
The code is
Z1 = genZ (- 2) fig.subplots_adjust (top=1, bottom=0, left=0, right=1) ax = plt.subplot () mBrots = [] for x in np.arange (0.5 out): C = x + x, 1j out = getJulia (z1Power40) im = ax.imshow (out.get), cmap=plt.cm.jet Animated=True) ax.set_axis_off () mBrots.append ([im]) ani = animation.ArtistAnimation (fig, mBrots, interval=50) plt.show () ani.save ('julia.gif',writer='imagemagick') this is how python draws cool dynamic Julia sets that Xiaobian shared with you. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.