@doc_params(scatter=doc_scatter)<EOL>def velocity_embedding_grid(adata, basis=None, vkey='<STR_LIT>', density=None, smooth=None, min_mass=None, arrow_size=None,<EOL>arrow_length=None, arrow_color=None, scale=None, autoscale=True, n_neighbors=None,<EOL>X=None, V=None, X_grid=None, V_grid=None, principal_curve=False, 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, projection='<STR_LIT>', legend_loc='<STR_LIT:none>',<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=density, autoscale=autoscale,<EOL>smooth=smooth, n_neighbors=n_neighbors, min_mass=min_mass)<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>": 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_grid(adata, density=density, scale=scale, size=size, min_mass=min_mass, smooth=smooth,<EOL>n_neighbors=n_neighbors, principal_curve=principal_curve, 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>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,<EOL>autoscale=False if len(vkeys) > <NUM_LIT:1> else autoscale, **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>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>": '<STR_LIT>', "<STR_LIT>": '<STR_LIT>', "<STR_LIT:width>": <NUM_LIT>,<EOL>"<STR_LIT>": '<STR_LIT>' if arrow_color is None else arrow_color, "<STR_LIT>": '<STR_LIT:k>',<EOL>"<STR_LIT>": hl/<NUM_LIT:2>, "<STR_LIT>": hw/<NUM_LIT:2>, "<STR_LIT>": hal/<NUM_LIT:2>, "<STR_LIT>": <NUM_LIT>}<EOL>quiver_kwargs.update(kwargs)<EOL>pl.quiver(X_grid[:, <NUM_LIT:0>], X_grid[:, <NUM_LIT:1>], V_grid[:, <NUM_LIT:0>], V_grid[:, <NUM_LIT:1>], **quiver_kwargs, zorder=<NUM_LIT:3>)<EOL>if principal_curve:<EOL><INDENT>curve = adata.uns['<STR_LIT>']['<STR_LIT>']<EOL>pl.plot(curve[:, <NUM_LIT:0>], curve[:, <NUM_LIT:1>], c="<STR_LIT:w>", lw=<NUM_LIT:6>, zorder=<NUM_LIT:4>)<EOL>pl.plot(curve[:, <NUM_LIT:0>], curve[:, <NUM_LIT:1>], c="<STR_LIT:k>", lw=<NUM_LIT:3>, zorder=<NUM_LIT:5>)<EOL><DEDENT>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>
\
    Scatter plot of velocities on a grid.

    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.
    min_mass: `float` (default: 0.5)
        Minimum threshold for mass to be shown.
    smooth: `float` (default: 0.5)
        Multiplication factor for scale in Gaussian kernel around grid point.
    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`