迭代公式的指数,使用的1+5j,这是个复数,所以是广义mandelbrot集,大家可以自行修改指数,得到其他图形。各种库安装不全的,自行想办法,可以在这个网站找到几乎所有的python库
http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib
#encoding=utf-8
import numpy as np
import pylab as pl
import time
from matplotlib import cm
from math import log
escape_radius = 10
iter_num = 20
def draw_mandelbrot2(cx, cy, d, N=600):
global mandelbrot
"""
绘制点(cx, cy)附近正负d的范围的Mandelbrot
"""
x0, x1, y0, y1 = cx-d, cx+d, cy-d, cy+d
y, x = np.ogrid[y0:y1:N*1j, x0:x1:N*1j]
c = x + y*1j
smooth_mand = np.frompyfunc(smooth_iter_point,1,1)(c).astype(np.float)
pl.gca().set_axis_off()
pl.imshow(smooth_mand, cmap=cm.Blues_r,