0

when I am plotting a graph using linspace for a and b values and plot it, it is plotting the samples along the axis and not the interval. for eg:

a=np.linspace(0,5,100)
b=np.linspace(0,6,100)

what is being plotted is 0-100 for a and b and not 0-5 and 0-6 on the graph. Can somebody help with this please

fig, ax = plt.subplots(1,1, figsize=(8,6), sharex=True)
a=np.linspace(0,5,1000)
b=np.linspace(0,6,1000)

def lyapunov(a,b):
a,b = np.meshgrid(a,b)
d = 0.3
xold = 0.5
yold = 0.01
ee = 0.
for k in range(1000):
    xnew=f(a,b,xold,yold)
    ynew=g(b,d,xold,yold)

    xold = xnew
    yold = ynew

ml=0   
for l in range(10000):
    ydash=1

    ml = ml + np.log(abs(e(a,b,xold,yold,ydash)))

    ydash = yz(a,b,xold,yold,ydash) 
    xold=f(a,b,xold,yold)
    yold=g(b,d,xold,yold)

ml = (ml/(2*10000))
ml[np.isnan(ml)] = -0.5
return ml


z = lyapunov(a,b)
print(z)

ax.set_title('Lyapunov Exponent')
c = ax.pcolormesh(z)
fig.colorbar(c)
plt.show()
Orla
  • 11
  • 1

1 Answers1

0

When you use a = np.linspace(0,5,100), that means, generate the variable "a" from 0 to 5 by using 100 points, so that returns an array with 100 points. When you use a = np.arange (0,5,1), that means, generate the variable "a" from 0 to 5-1 by stepping of 1, so that returns an array with five values. Output : array([0, 1, 2, 3, 4])

  • Yes thank you but I need there to be 100 points calculated between 0-5, but instead of 0-5 being labelled on graph it is labelling 0-100. I am unsure as to why it is doing this – Orla Apr 23 '19 at 13:32
  • My code with the values of a and b returns a graph (a ramp) of coordinates (a, b) = ([0-5], [0-6]). Can you show all your code, your plotting with matplotlib. – Sekouba Heisenberg Doumbouya Apr 23 '19 at 14:15