Skip to content

Commit d1f679c

Browse files
committed
update plot_cmap_legend
1 parent 1d4f09c commit d1f679c

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

PyComplexHeatmap/clustermap.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,11 +1142,9 @@ class ClusterMapPlotter:
11421142
legend :bool
11431143
True or False, whether to plot heatmap legend, determined by cmap.
11441144
legend_kws :dict
1145-
vmax, vmin and other kws passed to plot legend, such asfontsize,
1146-
fontsize, labelcolor, numpoints, markerscale, markerfirst, frameon
1147-
shadow, facecolor, edgecolor, title, title_fontsize, labelspacing and
1148-
so on (see ?plt.legend) Alaternatively, we can also change the
1149-
outline color and linewidth of cbar after plotting:
1145+
vmax, vmin and other kws passed to plot legend, such as
1146+
use_gridspec, location, orientation, fraction, shrink, aspect, pad, anchor, panchor,
1147+
extend, extendfrac, extendrect, ticks, format, drawedges, label, doundaries, values, spacing:
11501148
```
11511149
cm=ClusterMapPlotter(...)
11521150
for cbar in cm.cbars:
@@ -1156,6 +1154,8 @@ class ClusterMapPlotter:
11561154
cbar.dividers.set_color('red')
11571155
cbar.dividers.set_linewidth(2)
11581156
```
1157+
In addition to vmax,vmin, other parameters will be passed to https://matplotlib.org/stable/api/_as_gen/matplotlib.figure.Figure.colorbar.html#matplotlib.figure.Figure.colorbar
1158+
11591159
plot :bool
11601160
whether to plot or not.
11611161
plot_legend :bool
@@ -2302,7 +2302,7 @@ def collect_legends(self):
23022302
if self.legend:
23032303
self.legend_kws.setdefault("vmin", self.kwargs.get('vmin')) #round(vmin, 2))
23042304
self.legend_kws.setdefault("vmax", self.kwargs.get('vmax')) #round(vmax, 2))
2305-
self.legend_kws.setdefault("center", self.kwargs.get('center',None))
2305+
self.legend_kws.setdefault("center", self.kwargs.get('center', None))
23062306
self.legend_dict[self.label]=tuple([self.cmap, self.label, self.legend_kws, 4, "cmap"])
23072307
if len(self.yticklabels) > 0 and self.row_names_side == "right":
23082308
max_yticklabel_w = max(

PyComplexHeatmap/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ def plot_cmap_legend(
522522
ax : axes to anchor.
523523
cmap : turbo, hsv, Set1, Dark2, Paired, Accent,tab20,exp1,exp2,meth1,meth2
524524
label : title for legend.
525-
kws : kws passed to plt.colorbar.
525+
kws : dict
526+
kws passed to plt.colorbar (matplotlib.figure.Figure.colorbar).
526527
label_side : right or left.
527528
528529
Returns
@@ -540,6 +541,8 @@ def plot_cmap_legend(
540541
cbar_kws.setdefault("fraction", 1)
541542
cbar_kws.setdefault("shrink", 1)
542543
cbar_kws.setdefault("pad", 0)
544+
# cbar_kws.setdefault("extend", 'both')
545+
# cbar_kws.setdefault("extendfrac", 0.1)
543546
vmax = cbar_kws.pop("vmax", 1)
544547
vmin = cbar_kws.pop("vmin", 0)
545548
# print(vmin,vmax,'vmax,vmin')

notebooks/clustermap.ipynb

Lines changed: 8 additions & 5 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)