9  violin

import cellestial as cl
import scanpy as sc
from lets_plot import *

LetsPlot.setup_html()

data = sc.read("data/pbmc3k_mini.h5ad")

9.1 A simple Violin Plot

cl.violin(
    data,
    "pct_counts_in_top_50_genes",
    fill="sample",
    boxplot_color="#3f3f3f",
    show_points=True,
    outlier_shape=1,
)

9.2 Fill splits the data as in ggplot2

plot = cl.violin(
    data,
    "pct_counts_in_top_50_genes",
    fill="leiden",
    show_points=True,
    scale="width",
) + ggsize(1000, 400)

plot

9.3 Customize the plot

plot += scale_fill_brewer(palette="Set2") + scale_y_log2()
plot

9.4 Turn it into a interactive plot

Even if you did not create the plot with interactive = True you can still make it interactive with +ggtb() by lets_plot.

plot += ggtb()
plot
cl.versions()
cellestial: 0.6.0
scanpy: 1.10.4
anndata: 0.11.3
polars: 1.12.0