scanpy icon indicating copy to clipboard operation
scanpy copied to clipboard

Matplotlib default legend locations do not work with PCA plotting

Open jlehrer1 opened this issue 2 years ago • 0 comments

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)

import scanpy as sc 
import random 
import numpy as np

data = sc.datasets.pbmc3k()
sc.pp.pca(data)

# Make a dummy label column
data.obs['rand'] = np.random.randint(0, 5, data.obs.shape).astype(str)

sc.pl.pca(
    data,
    color='rand',
    legend_loc='upper right',  #or any other default in matplotlib 
)

You will see that the plot does not have any visible legend at all. This is consistent with other legend locations that are not 'on data' or 'None'


anndata 0.8.0 scanpy 1.9.1

PIL 9.0.1 appnope 0.1.2 asttokens NA attr 21.4.0 backcall 0.2.0 beta_ufunc NA binom_ufunc NA cffi 1.15.0 colorama 0.4.4 cycler 0.10.0 cython_runtime NA dateutil 2.8.2 debugpy 1.5.1 decorator 5.1.1 defusedxml 0.7.1 entrypoints 0.4 executing 0.8.3 fastjsonschema NA fontTools 4.33.3 google NA h5py 3.6.0 hypergeom_ufunc NA idna 3.3 ipykernel 6.13.0 ipython_genutils 0.2.0 ipywidgets 7.7.0 jedi 0.18.1 joblib 1.1.0 jsonschema 4.5.1 kaleido 0.2.1 kiwisolver 1.3.2 llvmlite 0.38.0 matplotlib 3.5.1 matplotlib_inline NA mpl_toolkits NA natsort 8.1.0 nbformat 5.4.0 nbinom_ufunc NA numba 0.55.1 numpy 1.20.3 packaging 21.3 pandas 1.4.1 parso 0.8.3 pexpect 4.8.0 pickleshare 0.7.5 pkg_resources NA plotly 5.8.0 prompt_toolkit 3.0.20 psutil 5.9.0 ptyprocess 0.7.0 pure_eval 0.2.2 pvectorc NA pycparser 2.21 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.12.0 pynndescent 0.5.7 pyparsing 3.0.9 pyrsistent NA pytz 2022.1 scipy 1.8.0 session_info 1.0.0 setuptools 61.2.0 six 1.16.0 sklearn 1.0.2 sphinxcontrib NA stack_data 0.2.0 tenacity NA threadpoolctl 3.1.0 tornado 6.1 tqdm 4.64.0 traitlets 5.1.1 typing_extensions NA umap 0.5.3 wcwidth 0.2.5 yaml 6.0 zipp NA zmq 22.3.0

IPython 8.2.0 jupyter_client 7.2.2 jupyter_core 4.9.2 notebook 6.4.11

Python 3.9.12 (main, Apr 5 2022, 01:53:17) [Clang 12.0.0 ] macOS-10.16-x86_64-i386-64bit

Session information updated at 2022-05-30 13:19

jlehrer1 avatar May 30 '22 20:05 jlehrer1