#64980·pandas

BUG: unintended side-effect of colorbar in plot()

Author: jpauwelsCreated Apr 1, 2026Updated Sep 29, 2026
LabelsBugVisualization

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

python
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
import pandas as pd

df = pd.DataFrame({
    'x': [1, 2, 3],
    'c': [0, 0, 0],
})
CMAP = ListedColormap(['blue', 'red'])

df.plot('x', 'x', kind='scatter', c=df['c'], colormap=CMAP, colorbar=False)
plt.show()

Issue Description

When using a binary colormap and all points have the same value, changing the value of colorbar affects the color of the scatter plot. Try switching between False and True for colorbar=.

Expected Behavior

Consistent behaviour independent of the presence of a colorbar or not.

Installed Versions

INSTALLED VERSIONS

commit : ab90747e3dae0e69b1bdbf083820b8075689b34b python : 3.14.3 python-bits : 64 OS : Darwin OS-release : 24.6.0 Version : Darwin Kernel Version 24.6.0: Mon Jan 19 22:00:10 PST 2026; root:xnu-11417.140.69.708.3~1/RELEASE_X86_64 machine : x86_64 processor : i386 byteorder : little LC_ALL : en_US.UTF-8 LANG : en_US.UTF-8 LOCALE : en_US.UTF-8

pandas : 3.0.2 numpy : 2.4.3 dateutil : 2.9.0.post0 pip : 26.0 Cython : None sphinx : None IPython : 9.6.0 adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.14.2 bottleneck : None fastparquet : None fsspec : None html5lib : None hypothesis : None gcsfs : None jinja2 : 3.1.6 lxml.etree : 6.0.2 matplotlib : 3.10.8 numba : None numexpr : None odfpy : None openpyxl : 3.1.5 psycopg2 : None pymysql : None pyarrow : None pyiceberg : None pyreadstat : None pytest : None python-calamine : None pytz : 2025.2 pyxlsb : None s3fs : None scipy : 1.17.1 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlsxwriter : None zstandard : None qtpy : None pyqt5 : None