scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.92k stars 602 forks source link

Rank_genes_groups -> does not return Axes #3205

Open dansteiert opened 3 months ago

dansteiert commented 3 months ago

Please make sure these conditions are met

What happened?

Function Rank_genes_groups() does not return a figure -> returns None type Cannot get Figure via plt.gcf(), plt.gca().

Potential Fix: https://github.com/scverse/scanpy/blob/main/src/scanpy/plotting/_tools/__init__.py Line 485: cann be extended to the following as in other functions below:

    savefig_or_show(f"{key}_", show=show, save=save)
    show = settings.autoshow if show is None else show
    if show:
        return None
    return ax

Minimal code sample

fig = sc.pl.rank_genes_groups(adata, show=False)
type(fig)
#NoneType
plt.gca() -> empty axes
plt.gcf() -> empty figure

Error output

No response

Versions

``` ----- anndata 0.10.8 scanpy 1.10.2 ----- ```
flying-sheep commented 3 weeks ago

The docs don’t say it does, so this would be an enhancement, not a bug fix.

it’s not high priority, since it’s easy to just do ax = plt.subplot(); sc.pl.rank_genes_groups(adata, ax=ax)

contributions are welcome!

dansteiert commented 2 weeks ago

This might be true the expected behaviour is not mentioned here. Then as you pointed out it is more of an enhancement, which would be to make it match other plotting functions behaviour ;)