How to specify linewidth in Seaborn's clustermap dendrograms

前端 未结 3 480
醉梦人生
醉梦人生 2021-01-21 19:53

Normally I would increase matplotlib\'s global linewidths by editing the matplotlib.rcParams. This seems to work well directly with SciPy\'s dendrogram implementation but not wi

3条回答
  •  太阳男子
    2021-01-21 20:29

    This has now been addressed in a more robust way by the following merged pull request https://github.com/mwaskom/seaborn/pull/1935. I'm assuming it will be included in the release after v0.9.0.

    You can control the LineCollection properties of the dendrogram by using the tree_kws parameter.

    For example:

    >>> import seaborn as sns
    >>> iris = sns.load_dataset("iris")
    >>> species = iris.pop("species")
    >>> g = sns.clustermap(iris, tree_kws=dict(linewidths=1.5, colors=(0.2, 0.2, 0.4))
    

    Would create a clustermap with 1.5 pt thick lines for the tree in an alternative dark purple color.

提交回复
热议问题