DotPlot.add_dendrogram(show=True, dendrogram_key=None, size=0.8)[source]#

Show dendrogram based on the hierarchical clustering between the groupby categories. Categories are reordered to match the dendrogram order.

The dendrogram information is computed using If has not been called previously the function is called with default parameters.

The dendrogram is by default shown on the right side of the plot or on top if the axes are swapped.

var_names are reordered to produce a more pleasing output if:
  • The data contains var_groups

  • the var_groups match the categories.

The previous conditions happen by default when using Plot to show the results from rank_genes_groups() (aka gene markers), by calling

show bool | None (default: True)

Boolean to turn on (True) or off (False) ‘add_dendrogram’

dendrogram_key str | None (default: None)

Needed if saved the dendrogram using a key different than the default name.

size float | None (default: 0.8)

size of the dendrogram. Corresponds to width when dendrogram shown on the right of the plot, or height when shown on top. The unit is the same as in matplotlib (inches).

Return type:



Returns self for method chaining.


>>> import scanpy as sc
>>> adata = sc.datasets.pbmc68k_reduced()
>>> markers = {'T-cell': 'CD3D', 'B-cell': 'CD79A', 'myeloid': 'CST3'}
>>> plot =, markers, groupby='bulk_labels').add_dendrogram()
>>> plot.plot_group_extra  
{'kind': 'dendrogram',
 'width': 0.8,
 'dendrogram_key': None,
 'dendrogram_ticks': array([0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5])}