troutpy.pl.crosstab#
- troutpy.pl.crosstab(sdata, xvar, yvar, layer='transcripts', normalize=True, axis=1, kind='barh', save=True, figures_path='', stacked=True, figsize=None, cmap='troutpy', saving_format='pdf', sortby=None)#
Generates a cross-tabulation plot between two categorical variables from
sdata.points.- Parameters:
sdata (spatialdata.SpatialData) – The input spatial data object containing the categorical variables.
xvar (str) – The categorical variable for the x-axis.
yvar (str) – The categorical variable for the y-axis.
layer (str) – The layer in
sdata.pointsto extract data from (default is “transcripts”).normalize (bool) – Whether to normalize proportions (default is True).
axis (int) – Axis to normalize across (1 = row, 0 = column).
kind (str) – Plot type: ‘barh’, ‘bar’, ‘heatmap’, ‘clustermap’.
save (bool) – Whether to save the plot (default is True).
figures_path (str) – Path to save the plot.
stacked (bool) – Whether bar plots should be stacked (default is True).
figsize (tuple) – Automatically computed based on the number of categories unless manually specified.
cmap (str) – Custom color palette.
saving_format (str) – File format to save the plot (e.g., ‘png’, ‘pdf’).
sortby (str) – Column/row to sort before plotting.
- Returns:
None