I want to plot a CCDF graph in Python by reading data from a text file "data.txt". Anyway, I got an error "ValueError: setting an array element with a sequence".
Can anyone help me?
Here is my code in python:
import matplotlib.pyplot as plt
import numpy as np
read = np.loadtxt('data.txt')
with open('data.txt') as f:
a = [map(float, line.split()) for line in f]
sorted=np.sort(a)
x2 = []
y2 = []
y = 0
for x in sorted:
x2.extend([x,x])
print x2
y2.append(y)
y += 1.0 / len(a)
y2.append(y)
plt.plot(x2,y2)
plt.show()
And here is my text file "data.txt":
9.500000000
2.500000000
3.500000000
4.500000000
6.500000000
1.500000000
read
array and then completely ignore it?x2
andy2
?