sc.pl.rank_genes_groups does not plot on subplot axes passed to the function
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 779
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 27
Description
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of scanpy.
- (optional) I have confirmed this bug exists on the master branch of scanpy.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Minimal code sample (that we can copy&paste without having any data)
fig, axs = plt.subplots(1, 3)
sc.tl.rank_genes_groups(ad, groupby = 'cluster', rankby_abs = True, groups = [1], reference = 0 , use_raw = False)
sc.pl.rank_genes_groups(ad, ax =axs[0], show = False)
sc.tl.rank_genes_groups(ad, groupby = 'cluster', rankby_abs = True, groups = [2], reference = 0, use_raw = False)
sc.pl.rank_genes_groups(ad, ax = axs[1], show = False)
sc.tl.rank_genes_groups(ad, groupby = 'cluster', rankby_abs = True, groups = [1], reference = 2 , use_raw = False)
sc.pl.rank_genes_groups(ad, ax = axs[2], show = False)
The empty subplot axes are plotted first:

then each sc.pl.rank_genes_groups is plotted correctly, but as a separate figure.
The documentation states that ax only works if you are plotting a single component, so I think it should work in this case, but it's also possible I'm doing something incorrectly.
Versions
anndata 0.8.0
scanpy 1.9.1
PIL 9.2.0
asttokens NA
backcall 0.2.0
beta_ufunc NA
binom_ufunc NA
cffi 1.15.0
colorama 0.4.5
cycler 0.10.0
cython_runtime NA
dateutil 2.8.2
debugpy 1.6.3
decorator 5.1.1
defusedxml 0.7.1
entrypoints 0.4
executing 1.0.0
google NA
h5py 3.7.0
hypergeom_ufunc NA
igraph 0.9.11
ipykernel 6.15.2
ipython_genutils 0.2.0
ipywidgets 8.0.2
jedi 0.18.1
joblib 1.1.0
jupyter_server 1.18.1
kiwisolver 1.4.2
leidenalg 0.8.10
llvmlite 0.39.1
matplotlib 3.5.3
matplotlib_inline 0.1.6
mpl_toolkits NA
natsort 8.2.0
nbinom_ufunc NA
ncf_ufunc NA
numba 0.56.2
numexpr 2.8.3
numpy 1.23.3
packaging 21.3
pandas 1.4.4
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
pkg_resources NA
prompt_toolkit 3.0.31
psutil 5.9.2
ptyprocess 0.7.0
pure_eval 0.2.2
pydev_ipython NA
pydevconsole NA
pydevd 2.8.0
pydevd_file_utils NA
pydevd_plugins NA
pydevd_tracing NA
pygments 2.13.0
pyparsing 3.0.9
pytz 2022.2.1
scipy 1.9.1
seaborn 0.12.0
session_info 1.0.0
setuptools 63.4.1
six 1.16.0
sklearn 1.1.2
stack_data 0.5.0
statsmodels 0.13.2
texttable 1.6.4
threadpoolctl 3.1.0
tornado 6.2
tqdm 4.64.1
traitlets 5.3.0
typing_extensions NA
wcwidth 0.2.5
yaml 6.0
zipp NA
zmq 23.2.1
IPython 8.5.0
jupyter_client 7.3.5
jupyter_core 4.11.1
jupyterlab 3.4.6
notebook 6.4.12
Python 3.8.0 (default, Nov 6 2019, 21:49:08) [GCC 7.3.0]
Linux-4.15.0-192-generic-x86_64-with-glibc2.10
Session information updated at 2022-10-28 15:05
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example with matplotlib subplots and the sc.pl.rank_genes_groups entry point. Inspect how the supplied ax argument is handled when plotting a single component, then verify that each call renders on its provided subplot rather than opening a separate figure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100