Skip to content

Instantly share code, notes, and snippets.

@stoffl6781
Created October 21, 2020 11:17
Show Gist options
  • Save stoffl6781/625a7ed1276d32c1021e502189398c91 to your computer and use it in GitHub Desktop.
Save stoffl6781/625a7ed1276d32c1021e502189398c91 to your computer and use it in GitHub Desktop.
Python Biorhythmus
from datetime import date
import matplotlib.dates
from pylab import *
from numpy import array,sin,pi
date_entry = input('Dein Geburtsdatum DD.MM.YYYY:')
day, month, year = map(int, date_entry.split('.'))
dob = datetime.date(year, month, day)
t0 = dob.toordinal()
t1 = date.today().toordinal()
t = array(range((t1-10),(t1+10))) # range of 20 days
y = 100*[sin(2*pi*(t-t0)/23), # Physical
sin(2*pi*(t-t0)/28), # Emotional
sin(2*pi*(t-t0)/33)]; # Intellectual
# converting ordinals to date
label = []
for p in t:
label.append(date.fromordinal(p))
fig = figure()
ax = fig.gca()
plot(label,y[0],label,y[1],label,y[2])
# adding a legend
legend(['Physical', 'Emotional', 'Intellectual'])
# formatting the dates on the x axis
ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%d/%b'))
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment