# [Matplotlib-users] Recursive fonctions (fractal tree)

Sergi for.mail at laposte.net
Sun Dec 8 10:35:04 EST 2019

```Hi, I have to create a reccursive function with matplotlib in order to make a
fractal tree.
That's my fonction at this moment :

import matplotlib.pyplot as plt
from math import *

def Drawn_(P,L,a,c,e):
X = L*cos(a) + P
Y = L*sin(a) + P
M=[X,Y]
plt.axis('equal')
plt.plot([P,X],[P,Y],color=c,lw=e)
return M

def Tree(P,L,k,a,N,c):
A=Drawn_(P,L,a+(pi/4),c,1)
while N>>0:
N=N-1
Arbre(A,L*k,k,0,N,'black')
Arbre(A,L*k,k,(pi/2),N,'green')

I had some pictures to show what are the problems.
<http://matplotlib.1069221.n5.nabble.com/file/t5278/1-What_I_have_to_do.jpg>
<http://matplotlib.1069221.n5.nabble.com/file/t5278/2-The_tree_that_I_have.jpg>

For the moment it don't work correctly because I can't create the tree with
random angles and I don't know how to solve the problem and create the
correct tree with recursivity..
Can someone help me please ? :)
I have to restart the fonction or can we had, or change somethings to make
it work ?

--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
```