turtle绘的正态分布图.py

李兴球Python之turtle normal distribute正态分布图

“””
turtle绘的正态分布图.py
“””
import turtle
import numpy as np

datas = [int(np.random.randn()*100) for _ in range(50000)]

print(min(datas))
print(max(datas))
counts = {}
for c in range(min(datas),max(datas)+1):
freq = datas.count(c) # 每个数产生的次数
counts[c] = freq # 放在字典中,如counts[3]=50,记录了3有50个

turtle.delay(0)
turtle.speed(0)
turtle.penup()
for key,value in counts.items():
turtle.goto(key,value)
turtle.dot(4)

turtle.done()

关于李兴球

李兴球的博客是Python创意编程原创博客
此条目发表在python, turtle分类目录。将固定链接加入收藏夹。

发表回复