forked from wiai/doorbot
add proper title and legend
parent
ad58e198f2
commit
7641a9d130
7
plot.py
7
plot.py
|
|
@ -1,5 +1,5 @@
|
|||
import argparse
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import date, datetime, timedelta
|
||||
import json
|
||||
|
||||
import requests
|
||||
|
|
@ -20,6 +20,7 @@ def parse_time(string):
|
|||
def plot(raw, target="wiai.png"):
|
||||
data = np.zeros([7, 24])
|
||||
last = (parse_time(raw[0]['timestamp']), 0)
|
||||
first = last
|
||||
increment = timedelta(hours=1)
|
||||
for log in raw:
|
||||
date = parse_time(log['timestamp'])
|
||||
|
|
@ -44,7 +45,11 @@ def plot(raw, target="wiai.png"):
|
|||
colors = [ im.cmap(im.norm(value)) for value in values ]
|
||||
patches = [ mpatches.Patch(color=colors[i], label=str(values[i])) for i in range(len(values))]
|
||||
plt.legend(handles=patches, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
|
||||
plt.title("Aggregated opening hours FS WIAI")
|
||||
plt.figtext(0.5, 0.25, "created: "+str(date.today()), ha="center")
|
||||
plt.figtext(0.5, 0.2, str(first[0])+" → "+str(last[0]), ha="center")
|
||||
plt.savefig(target, format="PNG", transparent=True, bbox_inches="tight")
|
||||
|
||||
return target
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue