'Feigenbaum logistic map

i'm having trouble to plot the feigenbaum logistic map, i made this code:

def logistic_map(r,x = 1./2,n = 1000):
   
    for i in range(n):
        x = i*x*(1-x)
    return x
r = np.arange(1,4,0.01)
x = np.zeros(len(r))

for i in r:
    x += logistic_map(i)
plt.plot(r,x,"k.")
plt.xlabel("r")
plt.ylabel("x")

can anyone tell what's wrong in this code, cause i'm getting the shapes wrong when i try to plot (r,x)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source