MatrixPlot.legend(show=True, title='Expression\\nlevel in group', width=1.5)

Configure legend parameters

show : Optional[bool] (default: True)

Set to ‘False’ to hide the default plot of the legend. This sets the legend width to zero which will result in a wider main plot.

title : Optional[str] (default: 'Expression\\nlevel in group')

Legend title. Appears on top of the color bar. Use ‘n’ to add line breaks.

width : Optional[float] (default: 1.5)

Width of the legend. The unit is the same as in matplotlib (inches)




Set legend title:

>>> adata = sc.datasets.pbmc68k_reduced()
>>> markers = {'T-cell': 'CD3D', 'B-cell': 'CD79A', 'myeloid': 'CST3'}
>>> dp =, markers, groupby='bulk_labels')
>>> dp.legend(colorbar_title='log(UMI counts + 1)').show()