From f6d6eefc3c0347c82a56c1c7a33c2ca6be061f60 Mon Sep 17 00:00:00 2001
From: Peter Swain <peter.swain@ed.ac.uk>
Date: Wed, 30 Aug 2023 13:45:29 +0100
Subject: [PATCH] renamed and added cmap to plot2Dhist

---
 plotting.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/plotting.py b/plotting.py
index ec7c78c..113e61d 100644
--- a/plotting.py
+++ b/plotting.py
@@ -297,7 +297,7 @@ def plot_replicate_array(
         plt.show(block=False)
 
 
-def plothist(
+def plot2Dhist(
     x,
     y,
     bins=[20, 20],
@@ -305,7 +305,9 @@ def plothist(
     figsize=None,
     xlabel="time",
     ylabel=None,
+    xmax=None,
     ymax=None,
+    cmap=None,
     **kwargs,
 ):
     """
@@ -332,8 +334,12 @@ def plothist(
         Label for the x-axis.
     ylabel: str (optional)
         Label for the y-axis.
+    xmax: float (optional)
+        The maximal value on the x-axis.
     ymax: float (optional)
         The maximal value on the y-axis.
+    cmap: matplotlib.colormap (optional)
+        Color map for the shading.
     **kwargs:
         Passed to plt.pcolormesh.
 
@@ -374,7 +380,10 @@ def plothist(
     # bin
     h, xedges, yedges = np.histogram2d(xn, yn, bins=bins)
     # make histogram
-    cmap = copy(plt.cm.viridis)
+    if cmap is None:
+        cmap = copy(plt.cm.viridis)
+    else:
+        cmap = copy(cmap)
     cmap.set_bad(cmap(0))
     # plot using pcolormesh
     if figsize is not None:
@@ -394,6 +403,8 @@ def plothist(
     plt.ylabel(ylabel)
     if ymax is not None:
         plt.ylim(top=ymax)
+    if xmax is not None:
+        plt.xlim(right=xmax)
     if title:
         plt.title(title)
     plt.tight_layout()
-- 
GitLab