Plotting multiple graphs does not work using pylab
<p>I want to visualize the <a href="https://en.wikipedia.org/wiki/Birthday_problem" rel="nofollow">Birthday Problem</a> with different <code>n</code>. My aim is to plot multiple graphs in the same figure but it does not work. It only plots the last graph and ignores the others. I am using the Jupyter Notebook. 
This is my Code:</p>

<pre><code>from decimal import Decimal

def calc_p_distinct(n):
    p_distinct = numpy.arange(0, n.size, dtype=Decimal)
    for i in n:
        p_distinct[i] = Decimal(1.0)

    for i in n:
        for person in range(i):
            p_distinct[i] = Decimal(p_distinct[i]) * Decimal(((Decimal(365-person))/Decimal(365)))

    return p_distinct


# n is the number of people
n = numpy.arange(0, 20)
n2 = numpy.arange(0, 50)
n3 = numpy.arange(0, 100)

# plot the probability distribution
p_distinct = calc_p_distinct(n)
pylab.plot(n, p_distinct, 'r')

p_distinct2 = calc_p_distinct(n2)
pylab.plot(n2, p_distinct2, 'g')

p_distinct3 = calc_p_distinct(n3)
pylab.plot(n3, p_distinct3, 'b')

# set the labels of the axis and title
pylab.xlabel("n", fontsize=18)
pylab.ylabel("probability", fontsize=18)
pylab.title("birthday problem", fontsize=20)

# show grid
pylab.grid(True)

# show the plot
pylab.show()
</code></pre>

<p>When I replace one of the calc_p_distinct() function calls with another built-in function (e.g. numpy.sin(n)), it will show me two graphs. So, I conclude that it must have something to do with my function. What am I doing wrong here?</p>

<p>This isn't a problem with <code>matplotlib</code>; all the lines are there, just on top of each other (which makes perfect sense; for 100 people, the probability for only the first 20 is the same as for a group of just 20 people).</p>

<p>If I quickly plot them with a different line width:</p>

<p><a href="http://i.stack.imgur.com/HbTFe.png" rel="nofollow"><img src="http://i.stack.imgur.com/HbTFe.png" alt="enter image description here"></a></p>

python matplotlib jupyter