@doc_params(scatter=doc_scatter)<EOL>def velocity_embedding_stream(adata, basis=None, vkey='<STR_LIT>', density=None, smooth=None, linewidth=None,<EOL>n_neighbors=None, X=None, V=None, X_grid=None, V_grid=None, color=None, use_raw=None,<EOL>layer=None, color_map=None, colorbar=True, palette=None, size=None, alpha=<NUM_LIT>, perc=None,<EOL>sort_order=True, groups=None, components=None, legend_loc='<STR_LIT>',<EOL>legend_fontsize=None, legend_fontweight=None, right_margin=None, left_margin=None,<EOL>xlabel=None, ylabel=None, title=None, fontsize=None, figsize=None, dpi=None, frameon=None,<EOL>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>velocity_embedding(adata, basis=basis, vkey=key)<EOL><DEDENT><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>if X_grid is None or V_grid is None:<EOL><INDENT>_adata = adata[groups_to_bool(adata, groups, groupby=color)]if groups is not None and color in adata.obs.keys() else adata<EOL>X_emb = _adata.obsm['<STR_LIT>' + basis][:, get_components(components, basis)] if X is None else X[:, :<NUM_LIT:2>]<EOL>V_emb = _adata.obsm[vkey + '<STR_LIT:_>' + basis][:, get_components(components, basis)] if V is None else V[:, :<NUM_LIT:2>]<EOL>X_grid, V_grid = compute_velocity_on_grid(X_emb=X_emb, V_emb=V_emb, density=<NUM_LIT:1>, smooth=smooth,<EOL>n_neighbors=n_neighbors, autoscale=False, adjust_for_stream=True)<EOL>lengths = np.sqrt((V_grid ** <NUM_LIT:2>).sum(<NUM_LIT:0>))<EOL>linewidth = <NUM_LIT:1> if linewidth is None else linewidth<EOL>linewidth *= <NUM_LIT:2> * lengths / lengths[~np.isnan(lengths)].max()<EOL><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>": 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_stream(adata, density=density, size=size, smooth=smooth, n_neighbors=n_neighbors,<EOL>linewidth=linewidth, ax=pl.subplot(gs),<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>X_grid=None if len(vkeys) > <NUM_LIT:1> else X_grid,<EOL>V_grid=None if len(vkeys) > <NUM_LIT:1> else V_grid, **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>ax = pl.figure(None, figsize, dpi=dpi).gca() if ax is None else ax<EOL>density = <NUM_LIT:1> if density is None else density<EOL>stream_kwargs = {"<STR_LIT>": linewidth, "<STR_LIT>": <NUM_LIT:2> * density}<EOL>stream_kwargs.update(kwargs)<EOL>pl.streamplot(X_grid[<NUM_LIT:0>], X_grid[<NUM_LIT:1>], V_grid[<NUM_LIT:0>], V_grid[<NUM_LIT:1>], color='<STR_LIT>', zorder=<NUM_LIT:3>, **stream_kwargs)<EOL>size = <NUM_LIT:4> * default_size(adata) if size is None else size<EOL>ax = scatter(adata, 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>
\
    Stream 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
    smooth: `float` (default: 0.5)
        Multiplication factor for scale in Gaussian kernel around grid point.
    linewidth: `float` (default: 1)
        Line width for streamplot.
    n_neighbors: `int` (default: None)
        Number of neighbors to consider around grid point.
    X: `np.ndarray` (default: None)
        Embedding grid point coordinates
    V: `np.ndarray` (default: None)
        Embedding grid velocity coordinates
    {scatter}

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