mechanochat.plotting.draw_legend#
- mechanochat.plotting.draw_legend(adata: AnnData | None = None, cluster_key: str | None = None, cmap: dict | None = None, ncol: int = 2, loc: str = 'center left', fontsize: float = 14., save_name: str | None = None, cid_list: ndarray[Any, dtype[int64]] | None = None, rename_map: Dict | None = None, ax: Axes | None = None)[source]#
Draw a standalone cell type legend, e.g. one shared by several panels.
- Parameters:
adata (
AnnData, optional) – AnnData with the annotation in .obs[cluster_key] and the colors in .uns[f’{cluster_key}_colors’]. If None, cmap must be givencluster_key (
str, optional) – Key of the cell type annotation in .obscmap (
dict, optional) – Explicit category -> color mapping, used when adata is Nonencol (
int, default2) – Number of legend columnsloc (
str, default'center left') – Matplotlib legend locationfontsize (
float, default14.) – Legend font sizesave_name (
str, optional) – Output path for figure saving (e.g., ‘figure.pdf’)cid_list (
ndarray, optional) – Restrict the legend to the categories present in these cells, keeping the original category order. Default: all cellsrename_map (
dict, optional) – Old name -> displayed name mapping for the categoriesax (
Axes, optional) – Target matplotlib axes object. Creates new figure if None
- Returns:
ax (
Axes)