Skip to content

Commit

Permalink
Update plot.py
Browse files Browse the repository at this point in the history
Fix a few bugs
  • Loading branch information
loftusa authored Apr 12, 2021
1 parent 116cf17 commit 3489094
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion graspologic/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ def binary_heatmap(
----------
X : nx.Graph or np.ndarray object
Unweighted graph or numpy matrix to plot.
colors : list-like or np.ndarray
A list of exactly two colors to use for the heatmap.
colorbar_ticklabels : list-like
Binary labels to use in the colorbar.
**kwargs : dict, optional
All keyword arguments in ``plot.heatmap``.
Expand All @@ -377,14 +383,16 @@ def binary_heatmap(
raise ValueError(
"cmap is not allowed in a binary heatmap. To change colors, use the `colors` parameter."
)
if not (isinstance(colorbar_ticklabels, (list, tuple)) and len(colorbar_ticklabels == 2)):
raise ValueError("colorbar_ticklabels must be list-like and length 2.")

cmap = mpl.colors.ListedColormap(colors)
ax = heatmap(X, center=None, cmap=cmap, **kwargs)
colorbar = ax.collections[0].colorbar
cbar = kwargs.setdefault("cbar", True)
if cbar:
colorbar.set_ticks([0.25, 0.75])
colorbar.set_ticklabels(["No Edge", "Edge"])
colorbar.set_ticklabels(colorbar_ticklabels)
colorbar.ax.set_frame_on(True)
return ax

Expand Down

0 comments on commit 3489094

Please sign in to comment.