def plot_matrix2(self, labels=None, **kwargs):
""" Plot distance matrix and dendrogram using seaborn. This package
needs to be installed manually.
Parameters
----------
kwargs dict
Keyword arguments to be passed to seaborn.clustermap. See
http://seaborn.pydata.org/generated/seaborn.clustermap.html
Returns
-------
seaborn.clustermap
"""
try:
import seaborn as sns
except:
raise ImportError('Need seaborn package installed.')
cg = sns.clustermap(
self.mat, row_linkage=self.linkage, col_linkage=self.linkage, **kwargs)
# Rotate labels
plt.setp(cg.ax_heatmap.xaxis.get_majorticklabels(), rotation=90)
plt.setp(cg.ax_heatmap.yaxis.get_majorticklabels(), rotation=0)
# Make labels smaller
plt.setp(cg.ax_heatmap.xaxis.get_majorticklabels(), fontsize=4)
plt.setp(cg.ax_heatmap.yaxis.get_majorticklabels(), fontsize=4)
# Increase padding
cg.fig.subplots_adjust(right=.8, top=.95, bottom=.2)
module_logger.info(
'Use matplotlib.pyplot.show() to render figure.')
return cg
评论列表
文章目录