Skip to content

BUG: Scatter plot has a hardcoded default value #54204

Open
@pgorczak

Description

@pgorczak

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 matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame(data=dict(x=[1,2,3], y=[1,2,3]))
fig, [[a1, a3], [a2, a4]] = plt.subplots(2,2, figsize=(10,10))
df.plot.scatter(x='x', y='y', ax=a1, title='pandas scatter, default rc marker size')
with mpl.rc_context({'lines.markersize': 10}):
    df.plot.scatter(x='x', y='y', ax=a3, title='pandas scatter, changed rc marker size')
    df.plot.line(x='x', y='y', marker='o', ax=a2, title='pandas line, changed rc marker size')
a4.scatter(df['x'], df['y'])
a4.set_title('matplotlib scatter, default rc marker size')

Issue Description

The current scatter plot implementation overwrites empty marker sizes with a hardcoded value of 20.

This means rc settings or style sheets can't be used to customize the scatter plot marker size. It has to be provided via DataFrame.plot.scatter(s=...) in every call.

Another inconsistency is that matplotlib default lines.markersize = 6 applies to matplotlib line and scatter plots as well as pandas line plots but not to pandas scatter plots. A pandas scatter plot and a matplotlib scatter plot have slightly different marker sizes even without touching any of the defaults. EDIT: Pandas scatter and line plots too

Expected Behavior

Use lines.markersize to style pandas scatter plots like matplotlib does since matplotlib/matplotlib#6202

Installed Versions

INSTALLED VERSIONS ------------------ commit : 0f43794 python : 3.9.16.final.0 python-bits : 64 OS : Darwin OS-release : 22.4.0 Version : Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:41 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8103 machine : arm64 processor : arm byteorder : little LC_ALL : en_US.UTF-8 LANG : en_US.UTF-8 LOCALE : en_US.UTF-8

pandas : 2.0.3
numpy : 1.25.1
pytz : 2023.3
dateutil : 2.8.2
setuptools : 68.0.0
pip : 22.1.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.1.2
IPython : 8.14.0
pandas_datareader: None
bs4 : 4.12.2
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 12.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : 1.4.29
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions