<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import matplotlib.pyplot as plt
import numpy as np


# Graficando el conjunto de Mandelbrot
def mandelbrot(h, w, maxit=20):
    """Crea el grafico del fractal de Mandelbrot del tamaÃ±o (h,w)."""
    y, x = np.ogrid[-1.4 : 1.4 : h * 1j, -2 : 0.8 : w * 1j]
    c = x + y * 1j
    z = c
    divtime = maxit + np.zeros(z.shape, dtype=int)

    for i in range(maxit):
        z = z**2 + c
        diverge = z * np.conj(z) &gt; 2**2
        div_now = diverge &amp; (divtime == maxit)
        divtime[div_now] = i
        z[diverge] = 2

    return divtime


plt.figure(figsize=(8, 8))
plt.imshow(mandelbrot(2000, 2000))
plt.show()
</pre></body></html>