replace legend with colorbar
parent
a1d3672357
commit
bac8b398bb
7
plot.py
7
plot.py
|
|
@ -6,7 +6,6 @@ import requests
|
||||||
import matplotlib
|
import matplotlib
|
||||||
matplotlib.use('Agg')
|
matplotlib.use('Agg')
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import matplotlib.patches as mpatches
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -41,13 +40,11 @@ def plot(raw, target="wiai.png"):
|
||||||
ax.set_yticks(np.arange(7))
|
ax.set_yticks(np.arange(7))
|
||||||
ax.set_yticklabels(DAYS_ABBR)
|
ax.set_yticklabels(DAYS_ABBR)
|
||||||
ax.set_xticks(np.arange(24))
|
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.title("Aggregated opening count FS WIAI")
|
||||||
plt.figtext(0.5, 0.25, "created: " + str(date.today()), 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")
|
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")
|
plt.savefig(target, format="PNG", transparent=True, bbox_inches="tight")
|
||||||
return target, last[0]
|
return target, last[0]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue