Skip to content

BUG: pd_df.plot issue: plotting several pd_df on the same figure, sometimes works, sometimes not #54561

@jerabaul29

Description

@jerabaul29

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

See the notebooks at:

Basically, all works fine in the first notebook. In the second notebook, doing exactly the same trick of .ploting twice on the same figure, I get an empty figure.

Issue Description

As visible in https://github.com/jerabaul29/public_bug_reports/blob/main/pandas/2023_08_15/SimpleScriptGetTideCurrentTimeseries.ipynb :

# this should work but plot is empty!
fig = plt.figure()
ax = plt.gca()
#
mask_pytmd = get_mask(df_pytmd, utc_timestamp_start, utc_timestamp_stop)
df_pytmd.loc[mask_pytmd].plot(x="utc_timestamp", y="pytmd_u", ax=ax)
#
mask_xr_obs = get_mask(df_xr_obs, utc_timestamp_start, utc_timestamp_stop)
df_xr_obs.loc[mask_xr_obs].plot(x="utc_timestamp", y=["xr_obs_u"], ax=ax)
#
plt.show()

Expected Behavior

This should plot both curves on the same figure.

Installed Versions

INSTALLED VERSIONS

commit : 0f43794
python : 3.11.4.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.0-78-generic
Version : #85~20.04.1-Ubuntu SMP Mon Jul 17 09:42:39 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.0.3
numpy : 1.25.2
pytz : 2023.3
dateutil : 2.8.2
setuptools : 68.0.0
pip : 23.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.14.0
pandas_datareader: None
bs4 : 4.12.2
bottleneck : None
brotli : 1.0.9
fastparquet : None
fsspec : 2023.6.0
gcsfs : None
matplotlib : 3.7.2
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.1
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : 2023.7.0
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions