scanpy.pl.DotPlot.legend

DotPlot.legend(show=True, show_size_legend=True, show_colorbar=True, size_title='Fraction of cells\\nin group (%)', colorbar_title='Mean expression\\nin group', width=1.5)

Configures dot size and the colorbar legends

Parameters
show : bool | NoneOptional[bool] (default: True)

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

show_size_legend : bool | NoneOptional[bool] (default: True)

Set to False to hide the dot size legend

show_colorbar : bool | NoneOptional[bool] (default: True)

Set to False to hide the colorbar legend

size_title : str | NoneOptional[str] (default: 'Fraction of cells\nin group (%)')

Title for the dot size legend. Use ‘n’ to add line breaks. Appears on top of dot sizes

colorbar_title : str | NoneOptional[str] (default: 'Mean expression\nin group')

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

width : float | NoneOptional[float] (default: 1.5)

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

Returns

DotPlot

Examples

Set color bar title:

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