Assuming you are using matplotlib to produce your graphs, see the 3rd example on
http://matplotlib.sourceforge.net/us..._tutorial.html
- The example with 3 sets of data on one graph (red dashes, blue squares and green triangles).
pyplot does accept multiple lists of y values as a single argument, but you'd need to test it to see how that works out. Given your situation, I think you should stick to the example's use of separate arguments for each list of y values.
I suspect things could also be made to work by calling pyplot multiple times and calling show just once. But I'm uncertain if pyplot will rescale the axes as needed if you toss numbers at it that don't fit on the scale picked for the earlier plots. I think it can autoscale, but without testing, I'm not sure how much you have to tell it for it to do the right thing.
If I may sound a louder cautionary note along the lines of dwblas's complaint that there's something funny about your while loops, I want you to note that his
for i in range(1,5):
runs with i=1, then 2, 3, 4 and then stops iterating. Your original loop ran i=0 (with special case code to make it a no-op), then 1, 2, 3, 4, 5.
I'm assuming you specifically wanted b[0] to be left with a value of 0, but if you really want b[5] to be set, the loop suggested by dwblas needs adjusting.
Sprinkling 5's and 6's throughout your code is setting yourself up for a maintenance nightmare. At a slight runtime cost, I suggest that you'll be much happier in the long run with code like
a=[0]*6 # Comment to explain why you picked 6 here
b=[0]*len(a)
Note that as coded above it is clear that however long a is, b is supposed to be the same length.
Similarly,
for i in range(len(a)):
will iterate for each index to the a list and will still be right even if you decided on a different length for a in some future revision of the code.
Want to skip a[0]? Then:
for i in range(1,len(a)):
will do it.
Clean coding counts in the long run!