Is there a library that would help me to neatly plot a probability mass function of a sample in python, like this:
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()
Here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With