import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
+from matplotlib.ticker import MaxNLocator
from io import BytesIO
import coffee_db as db
fig = plt.figure(figsize=(3, 3))
ax = fig.add_subplot(111)
ax.set_aspect(1)
- ax.pie(counts)
- ax.legend(flavors)
+ ax.pie(counts, autopct=lambda p: '{:.0f}'.format(p * sum(counts)/100) if p != 0 else '')
+ ax.legend(flavors, bbox_to_anchor=(1.0, 1.0))
ax.set_title("Your taste")
fig.savefig(b, format="svg", bbox_inches="tight")
b.seek(0)
ax.set_xticks(range(len(days)))
ax.set_xticklabels(xdays)
ax.set_title("Your week")
+ ax.yaxis.set_major_locator(MaxNLocator(integer=True))
fig.savefig(b, format="svg", bbox_inches="tight")
b.seek(0)
plt.close(fig)