I am plotting a set of numbers against their position in a file.
For instance, the first few lines of the file are shown below:
93
90
77
79
83
96
111
115
115
118
129
138
153
147
151
164
166
162
161
157
165
148
161
161
143
Now, I want to plot each number against the line number in the file.
X axis - line number in the file
Y axis - the value of the number at that specific line
I wrote the following code which plots the graph for first 5000 numbers in the file:
import matplotlib.pyplot as plt
import sys
X, Y = [], []
counter = 1
for line in open(sys.argv[1], 'r'):
X.append(float(counter))
Y.append(float(line))
counter = counter + 1
if counter > 5000:
break
plt.plot(X, Y)
plt.show()
The graph looks like shown below:
However, I want X-Axis to show more detailed intervals and the graph should look like below: