Logo image Logo image
  • Getting started
  • User Guide
  • API reference
  • Development
  • Release notes
  • Clustering package ( scipy.cluster )
  • K-means clustering and vector quantization ( scipy.cluster.vq )
  • Hierarchical clustering ( scipy.cluster.hierarchy )
  • Constants ( scipy.constants )
  • Discrete Fourier transforms ( scipy.fft )
  • Legacy discrete Fourier transforms ( scipy.fftpack )
  • Integration and ODEs ( scipy.integrate )
  • Interpolation ( scipy.interpolate )
  • Input and output ( scipy.io )
  • Linear algebra ( scipy.linalg )
  • Low-level BLAS functions ( scipy.linalg.blas )
  • Low-level LAPACK functions ( scipy.linalg.lapack )
  • BLAS Functions for Cython
  • LAPACK functions for Cython
  • Interpolative matrix decomposition ( scipy.linalg.interpolative )
  • Miscellaneous routines ( scipy.misc )
  • Multidimensional image processing ( scipy.ndimage )
  • Orthogonal distance regression ( scipy.odr )
  • Optimization and root finding ( scipy.optimize )
  • Cython optimize zeros API
  • Signal processing ( scipy.signal )
  • Sparse matrices ( scipy.sparse )
  • Sparse linear algebra ( scipy.sparse.linalg )
  • Compressed sparse graph routines ( scipy.sparse.csgraph )
  • Spatial algorithms and data structures ( scipy.spatial )
  • Distance computations ( scipy.spatial.distance )
  • Special functions ( scipy.special )
  • Statistical functions ( scipy.stats )
  • Result classes
  • Contingency table functions ( scipy.stats.contingency )
  • Statistical functions for masked arrays ( scipy.stats.mstats )
  • Quasi-Monte Carlo submodule ( scipy.stats.qmc )
  • Random Number Generators ( scipy.stats.sampling )
  • Low-level callback functions

scipy.cluster.hierarchy.set_link_color_palette#

scipy.cluster.hierarchy.set_link_color_palette(palette)[source]#

Set list of matplotlib color codes for use by dendrogram.

Note that this palette is global (i.e., setting it once changes the colors for all subsequent calls to dendrogram) and that it affects only the the colors below color_threshold.

Note that dendrogram also accepts a custom coloring function through its link_color_func keyword, which is more flexible and non-global.

Parameters
palettelist of str or None

A list of matplotlib color codes. The order of the color codes is the order in which the colors are cycled through when color thresholding in the dendrogram.

If None, resets the palette to its default (which are matplotlib default colors C1 to C9).

Returns
None

See also

dendrogram

Notes

Ability to reset the palette with None added in SciPy 0.17.0.

Examples

>>> from scipy.cluster import hierarchy
>>> ytdist = np.array([662., 877., 255., 412., 996., 295., 468., 268.,
...                    400., 754., 564., 138., 219., 869., 669.])
>>> Z = hierarchy.linkage(ytdist, 'single')
>>> dn = hierarchy.dendrogram(Z, no_plot=True)
>>> dn['color_list']
['C1', 'C0', 'C0', 'C0', 'C0']
>>> hierarchy.set_link_color_palette(['c', 'm', 'y', 'k'])
>>> dn = hierarchy.dendrogram(Z, no_plot=True, above_threshold_color='b')
>>> dn['color_list']
['c', 'b', 'b', 'b', 'b']
>>> dn = hierarchy.dendrogram(Z, no_plot=True, color_threshold=267,
...                           above_threshold_color='k')
>>> dn['color_list']
['c', 'm', 'm', 'k', 'k']

Now, reset the color palette to its default:

>>> hierarchy.set_link_color_palette(None)

previous

scipy.cluster.hierarchy.num_obs_linkage

next

scipy.cluster.hierarchy.DisjointSet

© Copyright 2008-2022, The SciPy community.

Created using Sphinx 4.5.0.