]> rtime.felk.cvut.cz Git - coffee/coffee-flask.git/commitdiff
Workaround the incompatibility created by Matplotlib 3.3.0
authorJaroslav Klapálek <klapajar@fel.cvut.cz>
Fri, 31 Jul 2020 05:16:56 +0000 (07:16 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Fri, 31 Jul 2020 08:40:39 +0000 (10:40 +0200)
app.py

diff --git a/app.py b/app.py
index 4989ee09462ef13d6f4def56bc16f4ad7d1708f1..d009705b817abd921fcbdbcbfc71e56180bd2069 100644 (file)
--- a/app.py
+++ b/app.py
@@ -124,8 +124,12 @@ def coffee_graph_flavors():
     fig = plt.figure(figsize=(3, 3))
     ax = fig.add_subplot(111)
     ax.set_aspect(1)
-    ax.pie(counts, autopct=lambda p: '{:.0f}'.format(p * sum(counts)/100) if p != 0 else '',
-           normalize=True)
+    if "normalize" in matplotlib.pyplot.pie.__code__.co_varnames:
+        ax.pie(counts, autopct=lambda p: '{:.0f}'.format(p * sum(counts)/100) if p != 0 else '',
+               normalize=True)
+    else:
+        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))
 
     if "uid" in session: