@doc_params(scatter=doc_scatter)<EOL>def velocity_embedding(adata, basis=None, vkey='<STR_LIT>', density=None, arrow_size=None, arrow_length=None, scale=None,<EOL>X=None, V=None, color=None, use_raw=None, layer=None, color_map=None, colorbar=True,<EOL>palette=None, size=None, alpha=<NUM_LIT>, perc=None, sort_order=True, groups=None, components=None,<EOL>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,<EOL>figsize=None, dpi=None, frameon=None, show=True, save=None, ax=None, ncols=None, **kwargs):
basis = default_basis(adata) if basis is None else basis<EOL>colors, layers, vkeys = make_unique_list(color, allow_array=True), make_unique_list(layer), make_unique_list(vkey)<EOL>for key in vkeys:<EOL><INDENT>if key + '<STR_LIT:_>' + basis not in adata.obsm_keys() and V is None:<EOL><INDENT>compute_velocity_embedding(adata, basis=basis, vkey=key)<EOL><DEDENT><DEDENT>scatter_kwargs = {"<STR_LIT>": basis, "<STR_LIT>": perc, "<STR_LIT>": use_raw, "<STR_LIT>": sort_order, "<STR_LIT>": alpha,<EOL>"<STR_LIT>": components, "<STR_LIT>": projection, "<STR_LIT>": legend_loc, "<STR_LIT>": groups,<EOL>"<STR_LIT>": legend_fontsize, "<STR_LIT>": legend_fontweight, "<STR_LIT>": palette,<EOL>"<STR_LIT>": color_map, "<STR_LIT>": frameon, "<STR_LIT>": xlabel, "<STR_LIT>": ylabel,<EOL>"<STR_LIT>": right_margin, "<STR_LIT>": left_margin, "<STR_LIT>": colorbar, "<STR_LIT>": dpi,<EOL>"<STR_LIT>": fontsize, "<STR_LIT>": False, "<STR_LIT>": None}<EOL>multikey = colors if len(colors) > <NUM_LIT:1> else layers if len(layers) > <NUM_LIT:1> else vkeys if len(vkeys) > <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>velocity_embedding(adata, density=density, scale=scale, size=size, ax=pl.subplot(gs),<EOL>arrow_size=arrow_size, arrow_length=arrow_length,<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>vkey=vkeys[i] if len(vkeys) > <NUM_LIT:1> else vkey,<EOL>title=title[i] if isinstance(title, (list, tuple)) else title,<EOL>**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>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>color, layer, vkey = colors[<NUM_LIT:0>], layers[<NUM_LIT:0>], vkeys[<NUM_LIT:0>]<EOL>color = default_color(adata) if color is None else color<EOL>size = default_size(adata) / <NUM_LIT:2> if size is None else size<EOL>_adata = adata[groups_to_bool(adata, groups, groupby=color)] if groups is not None and color in adata.obs.keys() else adata<EOL>density = <NUM_LIT:1> if density is None or density > <NUM_LIT:1> else density<EOL>ix_choice = np.random.choice(_adata.n_obs, size=int(density * _adata.n_obs), replace=False)<EOL>x, y = None if X is None else X[:, <NUM_LIT:0>], None if X is None else X[:, <NUM_LIT:1>]<EOL>X = _adata.obsm['<STR_LIT>' + basis][:, get_components(components, basis, projection)][ix_choice] if X is None else X[:, :<NUM_LIT:2>][ix_choice]<EOL>V = _adata.obsm[vkey + '<STR_LIT:_>' + basis][:, get_components(components, basis, projection)][ix_choice] if V is None else V[:, :<NUM_LIT:2>][ix_choice]<EOL>hl, hw, hal = default_arrow(arrow_size)<EOL>scale = <NUM_LIT:1> / arrow_length if arrow_length is not None else scale if scale is not None else <NUM_LIT:1><EOL>quiver_kwargs = {"<STR_LIT>": scale, "<STR_LIT>": color_map, "<STR_LIT>": '<STR_LIT>', "<STR_LIT>": '<STR_LIT>', "<STR_LIT:width>": <NUM_LIT>,<EOL>"<STR_LIT>": '<STR_LIT:k>', "<STR_LIT>": hl, "<STR_LIT>": hw, "<STR_LIT>": hal, "<STR_LIT>": <NUM_LIT>}<EOL>quiver_kwargs.update(kwargs)<EOL>c = interpret_colorkey(_adata, color, layer, perc)<EOL>c = c[ix_choice] if len(c) == _adata.n_obs else c<EOL>if projection == '<STR_LIT>' and X.shape[<NUM_LIT:1>] > <NUM_LIT:2> and V.shape[<NUM_LIT:1>] > <NUM_LIT:2>:<EOL><INDENT>V, size = V / scale / <NUM_LIT:5>, size / <NUM_LIT:10><EOL>x0, x1, x2, v0, v1, v2 = X[:, <NUM_LIT:0>], X[:, <NUM_LIT:1>], X[:, <NUM_LIT:2>], V[:, <NUM_LIT:0>], V[:, <NUM_LIT:1>], V[:, <NUM_LIT:2>]<EOL>quiver3d_kwargs = {"<STR_LIT>": <NUM_LIT:3>, "<STR_LIT>": <NUM_LIT>, "<STR_LIT>": <NUM_LIT>}<EOL>c = list(c) + [element for element in list(c) for _ in range(<NUM_LIT:2>)]<EOL>if is_color_like(c[<NUM_LIT:0>]): pl.quiver(x0, x1, x2, v0, v1, v2, color=c, **quiver3d_kwargs)<EOL>else: pl.quiver(x0, x1, x2, v0, v1, v2, c, **quiver3d_kwargs)<EOL><DEDENT>else:<EOL><INDENT>if is_color_like(c[<NUM_LIT:0>]): pl.quiver(X[:, <NUM_LIT:0>], X[:, <NUM_LIT:1>], V[:, <NUM_LIT:0>], V[:, <NUM_LIT:1>], color=c, zorder=<NUM_LIT:3>, **quiver_kwargs)<EOL>else: pl.quiver(X[:, <NUM_LIT:0>], X[:, <NUM_LIT:1>], V[:, <NUM_LIT:0>], V[:, <NUM_LIT:1>], c, zorder=<NUM_LIT:3>, **quiver_kwargs)<EOL><DEDENT>ax = scatter(adata, x=x, y=y, layer=layer, color=color, size=size, title=title, ax=ax, zorder=<NUM_LIT:0>, **scatter_kwargs)<EOL>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 of velocities on the embedding.

    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
    vkey: `str` or `None` (default: `None`)
        Key for annotations of observations/cells or variables/genes.
    density: `float` (default: 1)
        Amount of velocities to show - 0 none to 1 all
    arrow_size: `float` or 3-tuple for headlength, headwidth and headaxislength (default: 1)
        Size of arrows.
    arrow_length: `float` (default: 1)
        Length of arrows.
    scale: `float` (default: 1)
        Length of velocities in the embedding.
    {scatter}

    Returns
    -------
        `matplotlib.Axis` if `show==False`