scanpy
scanpy copied to clipboard
requesting ncols parameter in sc.pl.violin()
It would be nice to have a way to split the violin plots from sc.pl.violin()
into a specific number of rows, similar to the ncols
parameter in scanpy.pl.umap()
Any news on this ??
Also looking forward to this update
Looking forward to this update or is there any other way to achieve this?
It seems that the question has not be addressed yet, and still can't find the ncols parameter alike.
Pull requests welcome! You can achieve this e.g. like this:
import itertools
import math
import matplotlib.figure
import scanpy as sc
# parameters
ad = sc.datasets.pbmc68k_reduced()
vars = ["n_genes", "percent_mito", "n_counts", "S_score", "G2M_score"]
n_cols = 3
# plotting code
n_rows = math.ceil(len(vars) / n_cols)
fig = matplotlib.figure.Figure()
axs = fig.subplots(n_rows, 1)
for ax, v in zip(axs.flat, itertools.batched(vars, n_cols)):
sc.pl.violin(ad, v, ax=ax)
fig