Reputation: 89
I am trying to plot the content of the arrays x
and lj
in the following code. However, the point in the plots are not the one inside the arrays. Can someone help me see the mistake I did ? I am still new in python.
from matplotlib import pyplot as plt
import numpy as np
import math
lj=np.arange(10, dtype=np.float).reshape(10,1)
x=np.arange(10, dtype=np.float).reshape(10,1)
lj.fill(0)
x.fill(0)
for i in range(len(x)):
x[i,0]=i*0.1
lj[i,0]=4.0*( (1.0/(x[i,0]+0.0000001) )**12 - ( 1.0/(x[i,0]+0.0000001) )**6 )
for i in range(len(x)):
print(x[i,0],"\t\t\t",lj[i,0])
plt.plot(x,lj,"o")
plt.show()
This is the content of the arrayys and the follwoiing one is the plot done with plt.plot()
0.0 4e+84
0.1 3999948000335.996
0.2 976494140.831542
0.30000000000000004 7521188.628402116
0.4 237441.3028118298
0.5 16127.960985650918
0.6000000000000001 1751.8371605495026
0.7000000000000001 254.9905579573781
0.8 42.94879598363375
0.9 6.636105087302215
Upvotes: 0
Views: 178
Reputation: 58
Almost division by zero The plot is correct, lj[0] is almost equal to infinity, remove the first element, to get a better curve
Upvotes: 1