0

I currently have a text file where every even row (including zero) has x coordinates to a line and the odd rows have y the coordinates. These lines pair up, meaning row 0 (x coordinates) and row 1 (y coordinates) make a line. I have many of these rows, how would I plot these rows lines all on one graph using python? Also, side tracking a bit, is there some file that runs a .py script but without having to have python, kind of like an executable file, except for python.

user1939991
  • 187
  • 4
  • 14
  • for your second question, if what you mean is to generate an executable file, try cx_freeze or py2exe – laike9m Feb 09 '14 at 05:31

1 Answers1

0

Read in the data like this:

with open('file.txt') as f:
    coords = f.read().split()
x_coords = data[0::2]
y_coords = data[1::2]

Manipulating the data and using a library should let you plot the points. Here is an example with matplotlib:

import matplotlib
matplotlib.use('Agg') # http://stackoverflow.com/a/3054314/827437

import matplotlib.pyplot as plt
plt.plot(x_coords, y_coords, 'ro')
plt.savefig('plot.png')
vinod
  • 2,358
  • 19
  • 26