slice#
- slice(grid: SupPlotsSpec, index: int | Sequence[int], **kwargs) PlotSpec | SupPlotsSpec | None#
Slice a grid object (SupPlotsSpec) with the given index.
- Parameters:
grid (
SupPlotsSpec) – The grid to slice.index (
int | Sequence[int]) – The index or indices of the plots to slice.**kwargs (
dict[str,Any]) – Additional arguments for the gggrid function. see: https://lets-plot.org/python/pages/api/lets_plot.gggrid.html
- Returns:
PlotSpec | SupPlotsSpec– The sliced grid.- Raises:
TypeError – If the grid is not a SupPlotsSpec object. If the index is not an int or Sequence[int].
Examples
Get a single plot from a grid.
import scanpy as sc from lets_plot import * import cellestial as cl data = sc.read_h5ad("data/pbmc3k_pped.h5ad") grid = cl.expressions( data, keys=["MALAT1", "YBX3", "MNDA" ,"HLA-DRA"], axis_type="arrow", color_high="red", ncol=2, ) cl.slice(grid, index=3)
Get a multiple plots from a grid.
import scanpy as sc from lets_plot import * import cellestial as cl data = sc.read_h5ad("data/pbmc3k_pped.h5ad") grid = cl.expressions( data, keys=["MALAT1", "YBX3", "MNDA" ,"HLA-DRA"], axis_type="arrow", color_high="red", ncol=2, ) cl.slice(grid, index=[1,3])