This is my current code which is currently creating two images instead of zooming in. How would I change the code to create on fractal that zooms in its self? Thank you so much!
import numpy as np
import matplotlib.pyplot as plt
SIZE = 50
def testpoint(c, maxreps):
z = 0
reps = 0
while abs(z) < 2 and reps < maxreps:
z = z ** 2 + c
reps += 1
frac = float(reps) / float(maxreps)
return frac
def compute_mandelbrot(N_max, xmin, xmax, ymin, ymax, nx, ny):
# A grid of c-values
x = np.linspace(xmin, xmax, nx)
y = np.linspace(ymax, ymin, ny)
z = np.zeros([nx, ny])
for a in range(nx):
for b in range(ny):
z[a, b]=testpoint(complex(x[a], y[b]), N_max)
return z
if __name__ == '__main__':
xmin = -1.5
xmax = 0.5
ymin = -1
ymax = 1
pts = 800
mandelbrot_set = compute_mandelbrot(50, xmin, xmax, ymin, ymax, pts, pts)
plt.imshow(mandelbrot_set.T, extent=[xmin, xmax, ymin,ymax], cmap = plt.cm.rainbow)
plt.colorbar()
plt.show()
xmin = -1.0
xmax = 0.1
ymin = -0.5
ymax = 0.2
pts = 800
mandelbrot_set2 = compute_mandelbrot(50, xmin, xmax, ymin, ymax, pts, pts)
plt.imshow(mandelbrot_set2.T, extent=[xmin, xmax, ymin, ymax], cmap = plt.cm.rainbow)
plt.show()
I am trying to get the mandelbrot to zoom in on one image. Thank you!!