Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting PMF neatly in python

Is there a library that would help me to neatly plot a probability mass function of a sample in python, like this:

enter image description here

enter image description here

like image 699
amaatouq Avatar asked Feb 12 '15 17:02

amaatouq


1 Answers

Via matplotlib.pyplot's stem module

matplotlib.pyplot.stem(*args, **kwargs)

from matplotlib.pyplot import stem

stem(y, linefmt='b-', markerfmt='bo', basefmt='r-')
stem(x, y, linefmt='b-', markerfmt='bo', basefmt='r-')

or closer to the metal

#!/usr/bin/env python
from pylab import *

x = linspace(0.1, 2*pi, 10)
markerline, stemlines, baseline = stem(x, cos(x), '-.')
setp(markerline, 'markerfacecolor', 'b')
setp(baseline, 'color','r', 'linewidth', 2)

show()

enter image description here

Here

like image 97
hello_there_andy Avatar answered Sep 20 '22 14:09

hello_there_andy