python - Plotting multiple graphs does not work using pylab -


i want visualize birthday problem different n. aim plot multiple graphs in same figure not work. plots last graph , ignores others. using jupyter notebook. code:

from decimal import decimal  def calc_p_distinct(n):     p_distinct = numpy.arange(0, n.size, dtype=decimal)     in n:         p_distinct[i] = decimal(1.0)      in n:         person in range(i):             p_distinct[i] = decimal(p_distinct[i]) * decimal(((decimal(365-person))/decimal(365)))      return p_distinct   # n number of people n = numpy.arange(0, 20) n2 = numpy.arange(0, 50) n3 = numpy.arange(0, 100)  # plot 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 labels of axis , title pylab.xlabel("n", fontsize=18) pylab.ylabel("probability", fontsize=18) pylab.title("birthday problem", fontsize=20)  # show grid pylab.grid(true)  # show plot pylab.show() 

when replace 1 of calc_p_distinct() function calls built-in function (e.g. numpy.sin(n)), show me 2 graphs. so, conclude must have function. doing wrong here?

this isn't problem matplotlib; lines there, on top of each other (which makes perfect sense; 100 people, probability first 20 same group of 20 people).

if plot them different line width:

enter image description here


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -