Skip to content
Snippets Groups Projects
Commit f6d6eefc authored by pswain's avatar pswain
Browse files

renamed and added cmap to plot2Dhist

parent 09b10703
No related branches found
No related tags found
No related merge requests found
...@@ -297,7 +297,7 @@ def plot_replicate_array( ...@@ -297,7 +297,7 @@ def plot_replicate_array(
plt.show(block=False) plt.show(block=False)
def plothist( def plot2Dhist(
x, x,
y, y,
bins=[20, 20], bins=[20, 20],
...@@ -305,7 +305,9 @@ def plothist( ...@@ -305,7 +305,9 @@ def plothist(
figsize=None, figsize=None,
xlabel="time", xlabel="time",
ylabel=None, ylabel=None,
xmax=None,
ymax=None, ymax=None,
cmap=None,
**kwargs, **kwargs,
): ):
""" """
...@@ -332,8 +334,12 @@ def plothist( ...@@ -332,8 +334,12 @@ def plothist(
Label for the x-axis. Label for the x-axis.
ylabel: str (optional) ylabel: str (optional)
Label for the y-axis. Label for the y-axis.
xmax: float (optional)
The maximal value on the x-axis.
ymax: float (optional) ymax: float (optional)
The maximal value on the y-axis. The maximal value on the y-axis.
cmap: matplotlib.colormap (optional)
Color map for the shading.
**kwargs: **kwargs:
Passed to plt.pcolormesh. Passed to plt.pcolormesh.
...@@ -374,7 +380,10 @@ def plothist( ...@@ -374,7 +380,10 @@ def plothist(
# bin # bin
h, xedges, yedges = np.histogram2d(xn, yn, bins=bins) h, xedges, yedges = np.histogram2d(xn, yn, bins=bins)
# make histogram # 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)) cmap.set_bad(cmap(0))
# plot using pcolormesh # plot using pcolormesh
if figsize is not None: if figsize is not None:
...@@ -394,6 +403,8 @@ def plothist( ...@@ -394,6 +403,8 @@ def plothist(
plt.ylabel(ylabel) plt.ylabel(ylabel)
if ymax is not None: if ymax is not None:
plt.ylim(top=ymax) plt.ylim(top=ymax)
if xmax is not None:
plt.xlim(right=xmax)
if title: if title:
plt.title(title) plt.title(title)
plt.tight_layout() plt.tight_layout()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment