KrishnaswamyLab / scprep

A collection of scripts and tools for loading, processing, and handling single cell data.
MIT License
72 stars 19 forks source link

scprep.plot.scatter should handle bad matplotlib axis limits #87

Open scottgigante opened 5 years ago

scottgigante commented 5 years ago

Describe the bug Matplotlib chooses bad limits for data on extremely small scales

To Reproduce

import scprep
import numpy as np
x = np.repeat(np.linspace(0, 1, 10), 10)
y = np.tile(np.linspace(0, 1, 10), 10)
scprep.plot.scatter(x, y, c=np.arange(100), title="1")
scprep.plot.scatter(x*1e-2, y*1e-2, c=np.arange(100), title="1e-2")
scprep.plot.scatter(x*1e-5, y*1e-5, c=np.arange(100), title="1e-5")

Expected behavior All plots should appear the same up to a scaling of the axis limits.

Actual behavior

image image image

scprep version 1.0.1-a0

Output of pd.show_versions()

``` INSTALLED VERSIONS ------------------ commit : None python : 3.7.3.final.0 python-bits : 64 OS : Linux OS-release : 5.0.10-arch1-1-ARCH machine : x86_64 processor : byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 0.25.1 numpy : 1.17.0 pytz : 2019.1 dateutil : 2.8.0 pip : 19.0.3 setuptools : 41.0.1 Cython : 0.29.7 pytest : 4.4.1 hypothesis : None sphinx : 1.8.4 blosc : None feather : None xlsxwriter : None lxml.etree : 4.3.3 html5lib : 1.0.1 pymysql : None psycopg2 : None jinja2 : 2.10.1 IPython : 7.5.0 pandas_datareader: None bs4 : None bottleneck : 1.2.1 fastparquet : None gcsfs : None lxml.etree : 4.3.3 matplotlib : 3.0.3 numexpr : 2.6.9 odfpy : None openpyxl : 2.6.2 pandas_gbq : None pyarrow : None pytables : None s3fs : None scipy : 1.2.1 sqlalchemy : 1.3.3 tables : 3.5.2 xarray : None xlrd : 1.2.0 xlwt : 1.3.0 xlsxwriter : None ```
scottgigante commented 5 years ago

Template of a fix would modify the default axis limits if the range of the data is less than 1e-1. This would likely fit into _ScatterParams but could also be a fix in matplotlib itself.

scottgigante commented 5 years ago

Relates to #45

scottgigante commented 4 years ago

Added a bug report to matplotlib: https://github.com/matplotlib/matplotlib/issues/16539

scottgigante commented 4 years ago

Will be fixed in matplotlib 3.2