From 95638923c115f2f4d66bab2eee21a35499793305 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Wed, 24 May 2023 12:48:49 +0200
Subject: [PATCH] Use OO-style

---
 Inst_eddies/Analysis/distribution_function.py | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/Inst_eddies/Analysis/distribution_function.py b/Inst_eddies/Analysis/distribution_function.py
index 9a0a4b82..610891fc 100755
--- a/Inst_eddies/Analysis/distribution_function.py
+++ b/Inst_eddies/Analysis/distribution_function.py
@@ -62,11 +62,11 @@ def fig_hist(xlabel, x, label):
     """Creates a complete figure with histogram. x and label can also be
     sequences."""
     
-    plt.figure()
-    plt.hist(x, bins = "auto", histtype = "step", label = label)
-    plt.xlabel(xlabel)
-    plt.ylabel("number of occurrences")
-    if label is not None: plt.legend()
+    fig, ax = plt.subplots()
+    ax.hist(x, bins = "auto", histtype = "step", label = label)
+    ax.set_xlabel(xlabel)
+    ax.set_ylabel("number of occurrences")
+    if label is not None: ax.legend()
 
 def fig_distr_funct(xlabel, x, label = None):
     """Creates a complete figure with distribution function. x must be a
@@ -74,18 +74,18 @@ def fig_distr_funct(xlabel, x, label = None):
 
     """
     
-    plt.figure()
+    fig, ax = plt.subplots()
     print(xlabel + ":")
 
     label_None = label is None
     if label_None: label = itertools.repeat(None)
         
     for xi, li in zip(x, label):
-        plot_distr_funct(xi, label = li)
+        plot_distr_funct(xi, li, ax)
         
-    plt.xlabel(xlabel)
-    plt.ylabel("distribution function")
-    if not label_None: plt.legend()
+    ax.set_xlabel(xlabel)
+    ax.set_ylabel("distribution function")
+    if not label_None: ax.legend()
     
 def plot_all(dict_list, label = None):
     """dict_list: list of dictionaries. label: list of labels, one label
-- 
GitLab