python numpy/matplotlib绘制生物节律曲线

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

import datetime
import math

def daysnow(birthdate):
return (datetime.date.today() – birthdate).days

def clockwise(days, p):
return math.sin(2*math.pi *(days % p) / p)

def clockwise_2(date, birthdate, p):
return math.sin(2*math.pi*((date – birthdate).days % p) / p)

base = datetime.date.today()
birthdate = datetime.date(年, 月, 日)
datelist = [base + datetime.timedelta(days=x) for x in range(-15, 15)]

dla = np.array(datelist)
dlb = np.array([clockwise_2(x, birthdate, 23) for x in datelist])
dlc = np.array([clockwise_2(x, birthdate, 28) for x in datelist])
dld = np.array([clockwise_2(x, birthdate, 33) for x in datelist])

plt.plot(dla, dlb, dla, dlc, dla, dld)
plt.show()

发表评论

电子邮件地址不会被公开。 必填项已用*标注