Skip to content

BUG: float values not using full range of colormap in DataFrame.plot() #49142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
itsapinhulk opened this issue Oct 17, 2022 · 4 comments
Closed
2 of 3 tasks
Labels

Comments

@itsapinhulk
Copy link

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import numpy as np
import pandas as pd

x = np.random.randn(1000, 3) * 10000
df = pd.DataFrame(x, columns = ['ColA', 'ColB', 'ColC'])
df.plot(kind='scatter', x='ColA', y='ColB', alpha=0.4,
        label='ColC', figsize=(10, 10), c=df['ColC'], colormap='jet',
        colorbar=True)
df.plot(kind='scatter', x='ColA', y='ColB', alpha=0.4,
        label='ColC', figsize=(10, 10), c=df['ColC'].astype(int), colormap='jet',
        colorbar=True)

Issue Description

The plot's colormap changes significantly depending on the type of column (float vs int) for the same range of values. In case of float data, it appears to be not using parts of the colormap.

In the reproducible code, rounding the data type to int results in the expected plot.

Screenshot 2022-10-17 020530

Expected Behavior

Both plot() calls should result in the second plot in the screenshot, the one that uses the full range of the colormap.

Installed Versions

INSTALLED VERSIONS

commit : 87cfe4e
python : 3.10.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.22621
machine : AMD64
processor : AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 1.5.0
numpy : 1.23.4
pytz : 2022.1
dateutil : 2.8.2
setuptools : 63.4.1
pip : 22.2.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.4.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli :
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.6.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.9.2
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None

@itsapinhulk itsapinhulk added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 17, 2022
@itsapinhulk itsapinhulk changed the title BUG: BUG: float values not using full range of colormap in DataFrame.plot() Oct 17, 2022
@mzeitlin11
Copy link
Member

Thanks for reporting this @itsapinhulk! Further investigation into fixing this would be very welcome.

@mzeitlin11 mzeitlin11 added Visualization plotting and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 20, 2022
@krasch
Copy link
Contributor

krasch commented Oct 29, 2022

I was able to reproduce this in pandas 1.5.0 (version that the bug reporter is using), but it works correctly in 1.5.1 and in current main. So might have already been fixed?

@itsapinhulk could you try if you still see this bug in pandas 1.5.1?

@mzeitlin11
Copy link
Member

Maybe fixed by #48734?

@itsapinhulk
Copy link
Author

Confirmed it is fixed on version 1.5.1. Thanks @krasch and @mzeitlin11 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants