]> rtime.felk.cvut.cz Git - coffee/coffee-flask.git/commitdiff
Suppress Matplotlib's deprecation warning
authorMichal Sojka <michal.sojka@cvut.cz>
Thu, 30 Jul 2020 06:47:06 +0000 (08:47 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Thu, 30 Jul 2020 06:47:06 +0000 (08:47 +0200)
The warning was:

    coffee-flask/app.py:127: MatplotlibDeprecationWarning:
    normalize=None does not normalize if the sum is less than 1 but
    this behavior is deprecated since 3.3 until two minor releases
    later. After the deprecation period the default value will be
    normalize=True. To prevent normalization pass normalize=False

app.py

diff --git a/app.py b/app.py
index 17d2a7c14fcc36d565854e5d021af8dfbab7e80b..4989ee09462ef13d6f4def56bc16f4ad7d1708f1 100644 (file)
--- a/app.py
+++ b/app.py
@@ -124,7 +124,8 @@ 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 '')
+    ax.pie(counts, autopct=lambda p: '{:.0f}'.format(p * sum(counts)/100) if p != 0 else '',
+           normalize=True)
     ax.legend(flavors, bbox_to_anchor=(1.0, 1.0))
 
     if "uid" in session: