-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Description
Code Sample, a copy-pastable example if possible
import pandas as pd
import matplotlib as mpl
mpl.rcParams['image.cmap'] = 'Greys'
df = pd.DataFrame(np.random.randn(1000, 2), columns=["a", "b"])
df["b"] = df["b"] + np.arange(1000)
df.plot.hexbin(x="a", y="b", gridsize=25) # this is not gray...
Problem description
I don't know if this is intentional behaviour, but plotting a data frame as hexbin with matplotlib, the matplotlib default colormap (e.g. set by the style sheet, via rcParams
, or whatever) is ignored due to this line:
https://github.com/pandas-dev/pandas/blob/master/pandas/plotting/_matplotlib/core.py#L1010
cmap = self.colormap or "BuGn"
What I would expect as a user is that pandas uses the default colormap I have set rather than "BuGn"
.
Simply changing this line to
cmap = self.colormap
is enough (since plt.cm.get_cmap(None)
will return the default color map). If you agree, I can submit a PR.
Expected Output
A gray hexbin plot.
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.3.0-26-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : de_DE.UTF-8
LOCALE : de_DE.UTF-8
pandas : 1.0.0
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 19.3.1
setuptools : 44.0.0
Cython : 0.29.14
pytest : 5.3.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.12.0
pandas_datareader: None
bs4 : 4.8.2
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.3.5
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : 3.6.1
tabulate : 0.8.6
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None