I'm trying to scatter or plot 2 sets of arrays using numpy and matplotlib. Everything is ok with the code except when I try to have lines instead of dots in my plot The plot is ok when I use :
from numpy import *
import matplotlib.pyplot as plt
positions=open('test.txt','r')
lines=positions.readlines()
for i in range(0,len(lines)):
line=lines[i]
values=line.split(" ")
x_val = [float(values[0])]
y_val = [float(values[1])]
# plt.scatter(x_val,y_val)
#Or
plt.plot(x_val,y_val,'ro')
plt.title(' Data')
plt.xlabel('x ')
plt.ylabel('y')
plt.show()
positions.close()
But when I replace plt.plot(x_val,y_val,'ro')
with plt.plot(x_val,y_val,'r')
, or plt.plot(x_val,y_val,'-')
What I get is merely a blank page!
I have no idea what the problem is, because I tried it with many many different options and yet the only option which works properly is having 'o'.