gpt4 book ai didi

python - 在 python 中整齐地绘制 PMF

转载 作者:太空狗 更新时间:2023-10-30 01:01:13 24 4
gpt4 key购买 nike

是否有一个库可以帮助我在 python 中巧妙地绘制样本的概率质量函数,如下所示:

enter image description here

enter image description here

最佳答案

通过 matplotlib.pyplot 的主干模块

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-')

或更接近金属

#!/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

关于python - 在 python 中整齐地绘制 PMF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28484444/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com