scverse / scverse/scanpy

sc.pl.violin doesn't return `ax` when it says it should

Open
#2,135 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area - Documentation 📒 Area - Plotting 🌺
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.

Minimal code sample (that we can copy&paste without having any data)
import scanpy as sc
adata = sc.datasets.pbmc3k()
out = sc.pl.violin(adata, keys=['CD8A', 'CD8B'], ax=None)
assert out is None

Should return an axis, as stated in the docs

Returns
-------
A :class:`~matplotlib.axes.Axes` object if `ax` is `None` else `None`.

Temporary workaround for those wanting a solution:

ax = sc.pl.violin(adata, keys=['CD8A', 'CD8B'], ax=None, show=False)
Versions
WARNING: If you miss a compact list, please try `print_header`!
-----
anndata     0.7.8
scanpy      1.8.2
sinfo       0.3.1
-----
PIL                         8.4.0
anndata                     0.7.8
asttokens                   NA
backcall                    0.2.0
cffi                        1.15.0
colorama                    0.4.4
cycler                      0.10.0
cython_runtime              NA
dateutil                    2.8.0
debugpy                     1.5.1
decorator                   5.1.1
defusedxml                  0.7.1
django                      4.0
executing                   0.8.2
google                      NA
h5py                        2.10.0
igraph                      0.9.8
ipykernel                   6.7.0
ipython_genutils            0.2.0
ipywidgets                  7.6.5
jedi                        0.18.1
joblib                      1.1.0
jupyter_server              1.13.3
kiwisolver                  1.3.2
leidenalg                   0.8.8
llvmlite                    0.37.0
matplotlib                  3.5.1
matplotlib_inline           NA
mpl_toolkits                NA
natsort                     8.0.2
numba                       0.54.1
numexpr                     2.8.0
numpy                       1.19.5
packaging                   21.3
pandas                      1.1.5
parso                       0.8.3
pexpect                     4.8.0
pickleshare                 0.7.5
pkg_resources               NA
prompt_toolkit              3.0.24
psutil                      5.8.0
ptyprocess                  0.7.0
pure_eval                   0.2.1
pydev_ipython               NA
pydevconsole                NA
pydevd                      2.6.0
pydevd_concurrency_analyser NA
pydevd_file_utils           NA
pydevd_plugins              NA
pydevd_tracing              NA
pygments                    2.10.0
pyparsing                   3.0.6
pytz                        2021.3
scanpy                      1.8.2
scipy                       1.5.3
scprep                      1.1.0
seaborn                     0.11.2
setuptools                  58.0.4
setuptools_scm              NA
sinfo                       0.3.1
six                         1.16.0
sklearn                     0.24.2
sphinxcontrib               NA
stack_data                  0.1.4
statsmodels                 0.13.1
tables                      3.6.1
texttable                   1.6.4
tornado                     6.1
tqdm                        4.62.3
traitlets                   5.1.1
typing_extensions           NA
wcwidth                     0.2.5
yaml                        6.0
zmq                         22.3.0
-----
IPython             8.0.0
jupyter_client      6.1.12
jupyter_core        4.9.1
jupyterlab          3.2.8
notebook            6.4.7
-----
Python 3.8.12 | packaged by conda-forge | (default, Oct 12 2021, 21:59:51) [GCC 9.4.0]
Linux-5.4.0-1064-gcp-x86_64-with-glibc2.10
16 logical CPU cores
-----
Session information updated at 2022-02-10 16:29

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the sc.pl.violin entry point and reproduce the minimal example using sc.datasets.pbmc3k(). Compare the documented return behavior for ax=None with the show=False workaround; done means ax=None returns a matplotlib Axes object while an explicitly supplied ax still returns None.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.