import numpy as np
import matplotlib.pyplot as plt
from numpy.random import random

T = np.arange(0,1000)
##
L = np.zeros([len(T)])

for i in T[1:] : 
    L[i] = L[i-1]+(1-2*(random()>0.5))



plt.plot(T,L)
plt.xlabel("Temps")
plt.ylabel("Position")
plt.show()
##
P = np.zeros([len(T),2])

for i in T[1:]:
    angle = random()*2*np.pi
    P[i] = P[i-1] + np.array([np.cos(angle),np.sin(angle)])
    
    
fig = plt.figure() # initialise la figure
ax = plt.axes(aspect = 'equal')
plt.plot(P[:,0], P[:,1], zorder = 1)
plt.scatter(P[:,0], P[:,1], c =T,  cmap="jet" ,s = 7, zorder = 2)
ax.set_xlabel('X')
ax.set_ylabel('Y')
plt.colorbar(label = "Temps")

plt.show()