0

i've successfully wrote a code that plots the mandelbrot set, but now i try to put different colors according to the iterations before it diverges, but i just can't get it to work. here is my code, i don't know what's wrong with it ...

from math import *
import matplotlib.pyplot as plt


z=complex(0,0)

c=complex(2,2)
X=[]
Y=[]
Z=[]
p=1000
ite=30
a=-(4/p+4j/p)
for m in range(p):
    c=complex(2,c.imag+a.imag)
    for i in range(p):
        c=c+a.real
        z=complex(0,0)
        b=1
        for i in range(ite):
            b=b-0.005
            z=z**2+c
            if abs(z)>2:
                break

        X=X+[c.real]
        Y=Y+[c.imag]
        Z=Z+[b/30]


    print(round((m/p)*100),"%")
colors = Z
plt.scatter(X,Y,'.',c=[colors])
plt.show()

thanks in advance !

SlashBow
  • 1
  • 1
  • it says color array must be twi dimensional – SlashBow Mar 29 '15 at 17:54
  • 1
    When asking question, it is best to simplify as much as possible. So the problem here is not about Mandelbrot sets, but changing colors on a third variable. [This has already been asked and answered well in this post](http://stackoverflow.com/questions/7881994/matplotlib-how-to-change-data-points-color-based-on-some-variable). – Greg Mar 30 '15 at 08:02

0 Answers0