add proper title and legend
parent
ad58e198f2
commit
7641a9d130
7
plot.py
7
plot.py
|
|
@ -1,5 +1,5 @@
|
||||||
import argparse
|
import argparse
|
||||||
from datetime import datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
@ -20,6 +20,7 @@ def parse_time(string):
|
||||||
def plot(raw, target="wiai.png"):
|
def plot(raw, target="wiai.png"):
|
||||||
data = np.zeros([7, 24])
|
data = np.zeros([7, 24])
|
||||||
last = (parse_time(raw[0]['timestamp']), 0)
|
last = (parse_time(raw[0]['timestamp']), 0)
|
||||||
|
first = last
|
||||||
increment = timedelta(hours=1)
|
increment = timedelta(hours=1)
|
||||||
for log in raw:
|
for log in raw:
|
||||||
date = parse_time(log['timestamp'])
|
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 ]
|
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))]
|
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.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")
|
plt.savefig(target, format="PNG", transparent=True, bbox_inches="tight")
|
||||||
|
|
||||||
return target
|
return target
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue