It seems from the documentation like it should be possible to set all colorbar properties in seaborn.clustermap
or seaborn.heatmap
. Like the ticks in this example.
But the following gives an error in the colorbar initialization.
g = sns.clustermap(np.random.rand(5,20),
row_cluster=None, col_cluster=None, figsize=(8,3),
vmin = 0.25, vmax=1.0, cbar_kws={"aspect":50})
TypeError Traceback (most recent call last)
<ipython-input-29-820904ac4602> in <module>()
1 g = sns.clustermap(np.random.rand(5,20),
2 row_cluster=None, col_cluster=None, figsize=(8,3),
----> 3 vmin = 0.25, vmax=1.0, cbar_kws={"aspect":50})
~\AppData\Local\Continuum\Miniconda3\lib\site-packages\seaborn\matrix.py in clustermap(data, pivot_kws, method, metric, z_score, standard_scale, figsize, cbar_kws, row_cluster, col_cluster, row_linkage, col_linkage, row_colors, col_colors, mask, **kwargs)
1299 row_cluster=row_cluster, col_cluster=col_cluster,
1300 row_linkage=row_linkage, col_linkage=col_linkage,
-> 1301 **kwargs)
~\AppData\Local\Continuum\Miniconda3\lib\site-packages\seaborn\matrix.py in plot(self, metric, method, colorbar_kws, row_cluster, col_cluster, row_linkage, col_linkage, **kws)
1140
1141 self.plot_colors(xind, yind, **kws)
-> 1142 self.plot_matrix(colorbar_kws, xind, yind, **kws)
1143 return self
1144
~\AppData\Local\Continuum\Miniconda3\lib\site-packages\seaborn\matrix.py in plot_matrix(self, colorbar_kws, xind, yind, **kws)
1115 heatmap(self.data2d, ax=self.ax_heatmap, cbar_ax=self.cax,
1116 cbar_kws=colorbar_kws, mask=self.mask,
-> 1117 xticklabels=xtl, yticklabels=ytl, **kws)
1118
1119 ytl = self.ax_heatmap.get_yticklabels()
~\AppData\Local\Continuum\Miniconda3\lib\site-packages\seaborn\matrix.py in heatmap(data, vmin, vmax, cmap, center, robust, annot, fmt, annot_kws, linewidths, linecolor, cbar, cbar_kws, cbar_ax, square, xticklabels, yticklabels, mask, ax, **kwargs)
526 if square:
527 ax.set_aspect("equal")
--> 528 plotter.plot(ax, cbar_ax, kwargs)
529 return ax
530
~\AppData\Local\Continuum\Miniconda3\lib\site-packages\seaborn\matrix.py in plot(self, ax, cax, kws)
290 # Possibly add a colorbar
291 if self.cbar:
--> 292 cb = ax.figure.colorbar(mesh, cax, ax, **self.cbar_kws)
293 cb.outline.set_linewidth(0)
294 # If rasterized is passed to pcolormesh, also rasterize the
~\AppData\Local\Continuum\Miniconda3\lib\site-packages\matplotlib\figure.py in colorbar(self, mappable, cax, ax, use_gridspec, **kw)
1862 cax, kw = cbar.make_axes(ax, **kw)
1863 cax._hold = True
-> 1864 cb = cbar.colorbar_factory(cax, mappable, **kw)
1865
1866 self.sca(current_ax)
~\AppData\Local\Continuum\Miniconda3\lib\site-packages\matplotlib\colorbar.py in colorbar_factory(cax, mappable, **kwargs)
1366 cb = ColorbarPatch(cax, mappable, **kwargs)
1367 else:
-> 1368 cb = Colorbar(cax, mappable, **kwargs)
1369
1370 cid = mappable.callbacksSM.connect('changed', cb.on_mappable_changed)
~\AppData\Local\Continuum\Miniconda3\lib\site-packages\matplotlib\colorbar.py in __init__(self, ax, mappable, **kw)
944 kw['alpha'] = mappable.get_alpha()
945
--> 946 ColorbarBase.__init__(self, ax, **kw)
947
948 def on_mappable_changed(self, mappable):
TypeError: __init__() got an unexpected keyword argument 'aspect'
Which properties are actually allowed to be set? Is there another way to make the colorbar look better when the figure is not square? (probably aspect
is not even what I want, probably I actually want to change the bounding box).