hi all,

i'm getting very strange behavior from the matplotlib 'plot' function when attempting to plot multiple lines. i have a series of x, y data points that are being generated in a loop and i want to simply plot each of them on the same plot. my code is:

import matplotlib
import matplotlib.pyplot as plt
from matplotlib import rc
plt.rcParams['ps.useafm'] = True

my_fig = plt.figure(figsize=(6,5), dpi=100)
num_lines = 3

for n in range(0, num_lines):
    print "Printing line %d" %(n+1)
    x = range(0, 100)
    y = (ones(100)*(n+1))
    plt.plot(x, y)


when I do this, it only plots the last line (a horizontal line at y = 3). how can i get to actually plot all three lines?

more strangely, it shows *stochastic* behavior: sometimes when i run the code, it generates a green line at y = 3, and other times a blue line. from plot to plot, the upper bound of the y axis changes, sometimes being 3.15, sometimes 3.2.  i'm not sure why it is doing that.

how can i get it to simply add whatever i plot in the body of the 'for' loop to the same graph? i tried adding plt.plot() after my call to plt.plot but that did not fix it.

thank you.