xyplot#
API pages include interactive (HTML) plots that would possibly not render correctly on a mobile device.
- xyplot(data: AnnData, x: str, y: str, *, frame: DataFrame | None = None, mapping: FeatureSpec | None = None, axis: Literal[0, 1] | None = None, add_columns: Sequence[str] | str | None = None, tooltips: Literal['none'] | Sequence[str] | FeatureSpec | None = None, interactive: bool = False, observations_name: str = 'Barcode', variables_name: str = 'Variable', include_dimensions: bool | int = False, **point_kwargs) PlotSpec#
Scatter Plot.
- Parameters:
data (
AnnData) – The AnnData object of the single cell data.x (
str) – The key for the x-axis.y (
str) – The key for the y-axis.frame (
DataFrame | None, defaultNone) – A prebuilt frame to plot from. If provided, the frame is used directly and building from data is skipped. Must contain the x, y and mapping columns.mapping (
FeatureSpec | None, defaultNone) – Additional aesthetic mappings for the plot, the result of aes().axis (
{0,1}| None, defaultNone) – axis of the data, 0 for observations and 1 for variables.add_columns (
str | Sequence[str] | None, defaultNone) – Extra metadata columns or variable names to materialise into the frame, on top of those inferred from mapping and tooltips.tooltips (
{'none'}| Sequence[str] | FeatureSpec | None, defaultNone) – Tooltips to show when hovering over the geom. Accepts Sequence[str] or result of layer_tooltips() for more complex tooltips. Use ‘none’ to disable tooltips.interactive (
bool, defaultFalse) – Whether to make the plot interactive.observations_name (
str, default'Barcode') – The name to give to barcode (or index) column in the dataframe.variables_name (
str, default'Variable') – The name to give to variable index column in the dataframe.include_dimensions (
bool | int, defaultFalse) – Whether to include dimensions in the DataFrame. Providing an integer will limit the number of dimensions to given number.**point_kwargs – Additional parameters for the geom_point layer. For more information on geom_point parameters, see: https://lets-plot.org/python/pages/api/lets_plot.geom_point.html
- Returns:
PlotSpec– Scatter plot.- Raises:
UnsupportedDataTypeError – If data is not a supported single-cell data object.
Examples
xyplot requires x and y values to be provided directly.
import scanpy as sc from lets_plot import * import cellestial as cl data = cl.datasets.pbmc3k(cache_directory="data") cl.xyplot( data, x="n_genes_by_counts", y="pct_counts_in_top_50_genes", color="grey", alpha=0.6, )
xyplot also supports customization of aesthetics via mapping.
import scanpy as sc from lets_plot import * import cellestial as cl data = cl.datasets.pbmc3k(cache_directory="data") cl.xyplot( data, x="n_genes_by_counts", y="pct_counts_in_top_50_genes", mapping=aes(color="cell_type_lvl1"), alpha=0.6, ) + scale_color_viridis()
Faceting by categorical data is also possible.
import scanpy as sc from lets_plot import * import cellestial as cl data = cl.datasets.pbmc3k(cache_directory="data") cl.xyplot( data, x="n_genes_by_counts", y="pct_counts_in_top_50_genes", mapping=aes(color="cell_type_lvl1"), alpha=0.6, ) + scale_color_viridis() + facet_wrap("cell_type_lvl1")