diff --git a/Inst_eddies/Analysis/distribution_function.py b/Inst_eddies/Analysis/distribution_function.py
index 9a0a4b82884977c219b6d8c6f89894f01840d659..610891fc8c1ab4203548093560c57bceeac2faa6 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