@doc_params(scatter=doc_scatter)<EOL>def scatter(adata=None, x=None, y=None, basis=None, vkey=None, color=None, use_raw=None, layer=None, color_map=None,<EOL>colorbar=True, palette=None, size=None, alpha=None, linewidth=None, perc=None, sort_order=True, groups=None,<EOL>components=None, projection='<STR_LIT>', legend_loc='<STR_LIT:none>', legend_fontsize=None, legend_fontweight=None,<EOL>right_margin=None, left_margin=None, xlabel=None, ylabel=None, title=None, fontsize=None, figsize=None,<EOL>dpi=None, frameon=None, show=True, save=None, ax=None, zorder=None, ncols=None, **kwargs):
scatter_kwargs = {"<STR_LIT>": use_raw, "<STR_LIT>": sort_order, "<STR_LIT>": alpha, "<STR_LIT>": components,<EOL>"<STR_LIT>": projection, "<STR_LIT>": legend_loc, "<STR_LIT>": groups, "<STR_LIT>": palette,<EOL>"<STR_LIT>": legend_fontsize, "<STR_LIT>": legend_fontweight,<EOL>"<STR_LIT>": right_margin, "<STR_LIT>": left_margin, "<STR_LIT>": False, "<STR_LIT>": None}<EOL>adata = AnnData(np.stack([x, y]).T) if adata is None and (x is not None and y is not None) else adata<EOL>colors, layers, bases = make_unique_list(color, allow_array=True), make_unique_list(layer), make_unique_list(basis)<EOL>multikey = colors if len(colors) > <NUM_LIT:1> else layers if len(layers) > <NUM_LIT:1> else bases if len(bases) > <NUM_LIT:1> else None<EOL>if multikey is not None:<EOL><INDENT>if isinstance(title, (list, tuple)): title *= int(np.ceil(len(multikey) / len(title)))<EOL>ncols = len(multikey) if ncols is None else min(len(multikey), ncols)<EOL>nrows = int(np.ceil(len(multikey) / ncols))<EOL>figsize = rcParams['<STR_LIT>'] if figsize is None else figsize<EOL>for i, gs in enumerate(<EOL>pl.GridSpec(nrows, ncols, pl.figure(None, (figsize[<NUM_LIT:0>] * ncols, figsize[<NUM_LIT:1>] * nrows), dpi=dpi))):<EOL><INDENT>if i < len(multikey):<EOL><INDENT>scatter(adata, x=x, y=y, size=size, linewidth=linewidth, xlabel=xlabel, ylabel=ylabel, vkey=vkey,<EOL>color_map=color_map, colorbar=colorbar, perc=perc, frameon=frameon, ax=pl.subplot(gs), zorder=zorder,<EOL>color=colors[i] if len(colors) > <NUM_LIT:1> else color,<EOL>layer=layers[i] if len(layers) > <NUM_LIT:1> else layer,<EOL>basis=bases[i] if len(bases) > <NUM_LIT:1> else basis,<EOL>title=title[i] if isinstance(title, (list, tuple)) else title, **scatter_kwargs, **kwargs)<EOL><DEDENT><DEDENT>savefig_or_show('<STR_LIT>' if basis is None else basis, dpi=dpi, save=save, show=show)<EOL>if not show: return ax<EOL><DEDENT>else:<EOL><INDENT>color, layer, basis = colors[<NUM_LIT:0>], layers[<NUM_LIT:0>], bases[<NUM_LIT:0>]<EOL>color = default_color(adata) if color is None else color<EOL>color_map = default_color_map(adata, color) if color_map is None else color_map<EOL>is_embedding = ((x is None) | (y is None)) and basis not in adata.var_names<EOL>basis = default_basis(adata) if basis is None and is_embedding else basis<EOL>size = default_size(adata) if size is None else size<EOL>linewidth = <NUM_LIT:1> if linewidth is None else linewidth<EOL>frameon = frameon if frameon is not None else True if not is_embedding else settings._frameon<EOL>if projection == '<STR_LIT>':<EOL><INDENT>from mpl_toolkits.mplot3d import Axes3D<EOL>ax = pl.figure(None, figsize, dpi=dpi).gca(projection=projection) if ax is None else ax<EOL><DEDENT>else:<EOL><INDENT>ax = pl.figure(None, figsize, dpi=dpi).gca() if ax is None else ax<EOL><DEDENT>if is_categorical(adata, color) and is_embedding:<EOL><INDENT>from scanpy.api.pl import scatter as scatter_<EOL>ax = scatter_(adata, basis=basis, color=color, color_map=color_map, size=size, frameon=frameon, ax=ax,<EOL>title=title, **scatter_kwargs, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>if basis in adata.var_names:<EOL><INDENT>xkey, ykey = ('<STR_LIT>', '<STR_LIT>') if use_raw or '<STR_LIT>' not in adata.layers.keys() else ('<STR_LIT>', '<STR_LIT>')<EOL>x = make_dense(adata[:, basis].layers[xkey])<EOL>y = make_dense(adata[:, basis].layers[ykey])<EOL>xlabel, ylabel = '<STR_LIT>', '<STR_LIT>'<EOL>title = basis if title is None else title<EOL><DEDENT>elif is_embedding:<EOL><INDENT>X_emb = adata.obsm['<STR_LIT>' + basis][:, get_components(components, basis)]<EOL>x, y = X_emb[:, <NUM_LIT:0>], X_emb[:, <NUM_LIT:1>]<EOL><DEDENT>elif isinstance(x, str) and isinstance(y, str) and x in adata.var_names and y in adata.var_names:<EOL><INDENT>x = adata[:, x].layers[layer] if layer in adata.layers.keys() else adata[:, x].X<EOL>y = adata[:, y].layers[layer] if layer in adata.layers.keys() else adata[:, y].X<EOL><DEDENT>if basis in adata.var_names and isinstance(color, str) and color in adata.layers.keys():<EOL><INDENT>c = interpret_colorkey(adata, basis, color, perc)<EOL><DEDENT>else:<EOL><INDENT>c = interpret_colorkey(adata, color, layer, perc)<EOL><DEDENT>if layer is not None and '<STR_LIT>' in layer and isinstance(color, str) and color in adata.var_names:<EOL><INDENT>ub = np.percentile(np.abs(c), <NUM_LIT>)<EOL>kwargs.update({"<STR_LIT>": -ub, "<STR_LIT>": ub})<EOL><DEDENT>if layer is not None and ('<STR_LIT>' in layer or '<STR_LIT>' in layer or '<STR_LIT>' in layer)and isinstance(color, str) and color in adata.var_names:<EOL><INDENT>ub = np.percentile(c, <NUM_LIT>)<EOL>kwargs.update({"<STR_LIT>": ub})<EOL><DEDENT>if groups is not None or np.any(pd.isnull(c)):<EOL><INDENT>zorder = <NUM_LIT:0> if zorder is None else zorder<EOL>ax = scatter(adata, basis=basis, color='<STR_LIT>', ax=ax, zorder=zorder, **scatter_kwargs)<EOL>zorder += <NUM_LIT:1><EOL><DEDENT>if basis in adata.var_names:<EOL><INDENT>fits = show_linear_fit(adata, basis, vkey, xkey, linewidth)<EOL>from .simulation import show_full_dynamics<EOL>if '<STR_LIT>' in adata.var.keys():<EOL><INDENT>fit = show_full_dynamics(adata, basis, '<STR_LIT:true>', use_raw, linewidth)<EOL>fits.append(fit)<EOL><DEDENT>if '<STR_LIT>' in adata.var.keys() and (vkey is None or '<STR_LIT>' in vkey):<EOL><INDENT>fit = show_full_dynamics(adata, basis, '<STR_LIT>', use_raw, linewidth,<EOL>show_assigments=vkey is not None and '<STR_LIT>' in vkey)<EOL>fits.append(fit)<EOL><DEDENT>if vkey is not None and '<STR_LIT>' in vkey:<EOL><INDENT>show_density(x, y)<EOL><DEDENT>if len(fits) > <NUM_LIT:0> and legend_loc is not None:<EOL><INDENT>pl.legend(fits, loc=legend_loc if legend_loc is not '<STR_LIT:none>' else '<STR_LIT>')<EOL><DEDENT>if use_raw and perc is not None:<EOL><INDENT>pl.xlim(right=np.percentile(x, <NUM_LIT> if not isinstance(perc, int) else perc) * <NUM_LIT>)<EOL>pl.ylim(top=np.percentile(y, <NUM_LIT> if not isinstance(perc, int) else perc) * <NUM_LIT>)<EOL><DEDENT><DEDENT>pl.scatter(x, y, c=c, cmap=color_map, s=size, alpha=alpha, edgecolors='<STR_LIT:none>', marker='<STR_LIT:.>', zorder=zorder, **kwargs)<EOL>set_label(xlabel, ylabel, fontsize, basis)<EOL>set_title(title, layer, color, fontsize)<EOL>ax = update_axes(ax, fontsize, is_embedding, frameon)<EOL>if colorbar and not is_categorical(adata, color): set_colorbar(ax)<EOL><DEDENT>savefig_or_show('<STR_LIT>' if basis is None else basis, dpi=dpi, save=save, show=show)<EOL>if not show: return ax<EOL><DEDENT>
\
    Scatter plot along observations or variables axes.

    Arguments
    ---------
    adata: :class:`~anndata.AnnData`
        Annotated data matrix.
    x: `str`, `np.ndarray` or `None` (default: `None`)
        x coordinate
    y: `str`, `np.ndarray` or `None` (default: `None`)
        y coordinate
    {scatter}

    Returns
    -------
        If `show==False` a `matplotlib.Axis`