From bac8b398bbd6751bf252c57bff53cce069cb6764 Mon Sep 17 00:00:00 2001 From: Clemens Klug Date: Tue, 13 Mar 2018 11:33:20 +0100 Subject: [PATCH] replace legend with colorbar --- plot.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/plot.py b/plot.py index 886375e..ee458cd 100644 --- a/plot.py +++ b/plot.py @@ -6,7 +6,6 @@ import requests import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt -import matplotlib.patches as mpatches import numpy as np @@ -41,13 +40,11 @@ def plot(raw, target="wiai.png"): ax.set_yticks(np.arange(7)) ax.set_yticklabels(DAYS_ABBR) ax.set_xticks(np.arange(24)) - - 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 count 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.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") + cax = plt.axes((0.95, 0.15, 0.05, 0.5)) + plt.colorbar(im, cax=cax) plt.savefig(target, format="PNG", transparent=True, bbox_inches="tight") return target, last[0]