我有以下jupyter笔记本代码,可将mandlebrot分形绘制50次并将其保存在50个不同的图像文件中。如果有人可以帮助我找出如何将每个图像放大到中心,我会很喜欢。我把数字弄乱了,但是如果我能放大一点并保持窗口稳定,我会喜欢的。谢谢!
import numpy
from numba import jit
import matplotlib.pyplot as plt
@jit
def mandlebrot(Re, Im, max_iter, zoom):
c = complex(Re, Im)
z = 0.0j
for i in range(max_iter):
z = (z*z) + c
if(z.real*z.real + z.imag*z.imag) >= 4:
return i
return max_iter
zoom = 1
for i in range(50):
columns = 1920
rows = 1080
result = numpy.zeros([rows, columns])
for row_index, Re in enumerate(numpy.linspace(-2, 1, num = rows)):
for column_index, Im in enumerate(numpy.linspace(-1, 1, num = columns)):
result[row_index, column_index] = mandlebrot(Re, Im, 50, zoom)
plt.figure(dpi = 100)
plt.imshow(result.T, cmap = 'hot', interpolation = 'bilinear', extent = [-2, 1, -1, 1])
zoom+=.05
plt.xlabel('Real')
plt.ylabel('Imaginary')
filepath = r"C:\Users\Riley\Desktop\mandlebrot\mandlebrot" + str(i) + ".png"
plt.savefig(filepath)
plt.close()