scanpy.pl.DotPlot.style

Contents

scanpy.pl.DotPlot.style#

DotPlot.style(*, cmap='winter', color_on='dot', dot_max=None, dot_min=None, smallest_dot=0.0, largest_dot=200.0, dot_edge_color='black', dot_edge_lw=0.2, size_exponent=1.5, grid=False, x_padding=0.8, y_padding=1.0)[source]#

Modifies plot visual parameters

Parameters:
cmap str (default: 'winter')

String denoting matplotlib color map.

color_on Optional[Literal['dot', 'square']] (default: 'dot')

Options are ‘dot’ or ‘square’. Be default the colomap is applied to the color of the dot. Optionally, the colormap can be applied to an square behind the dot, in which case the dot is transparent and only the edge is shown.

dot_max float | None (default: None)

If none, the maximum dot size is set to the maximum fraction value found (e.g. 0.6). If given, the value should be a number between 0 and 1. All fractions larger than dot_max are clipped to this value.

dot_min float | None (default: None)

If none, the minimum dot size is set to 0. If given, the value should be a number between 0 and 1. All fractions smaller than dot_min are clipped to this value.

smallest_dot float | None (default: 0.0)

If none, the smallest dot has size 0. All expression fractions with dot_min are plotted with this size.

largest_dot float | None (default: 200.0)

If none, the largest dot has size 200. All expression fractions with dot_max are plotted with this size.

dot_edge_color Union[str, tuple[float, ...], None] (default: 'black')

Dot edge color. When color_on='dot' the default is no edge. When color_on='square', edge color is white for darker colors and black for lighter background square colors.

dot_edge_lw float | None (default: 0.2)

Dot edge line width. When color_on='dot' the default is no edge. When color_on='square', line width = 1.5.

size_exponent float | None (default: 1.5)

Dot size is computed as: fraction ** size exponent and afterwards scaled to match the smallest_dot and largest_dot size parameters. Using a different size exponent changes the relative sizes of the dots to each other.

grid float | None (default: False)

Set to true to show grid lines. By default grid lines are not shown. Further configuration of the grid lines can be achieved directly on the returned ax.

x_padding float | None (default: 0.8)

Space between the plot left/right borders and the dots center. A unit is the distance between the x ticks. Only applied when color_on = dot

y_padding float | None (default: 1.0)

Space between the plot top/bottom borders and the dots center. A unit is the distance between the y ticks. Only applied when color_on = dot

Returns:

DotPlot

Examples

>>> import scanpy as sc
>>> adata = sc.datasets.pbmc68k_reduced()
>>> markers = ['C1QA', 'PSAP', 'CD79A', 'CD79B', 'CST3', 'LYZ']

Change color map and apply it to the square behind the dot

>>> sc.pl.DotPlot(adata, markers, groupby='bulk_labels') \
...     .style(cmap='RdBu_r', color_on='square').show()

Add edge to dots and plot a grid

>>> sc.pl.DotPlot(adata, markers, groupby='bulk_labels') \
...     .style(dot_edge_color='black', dot_edge_lw=1, grid=True) \
...     .show()