Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BUG: Subplot data is lost when sharex=True and latter DatetimeIndex has higher frequency #55110

Copy link
Copy link
Open
@jluttine

Description

@jluttine
Issue body actions

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.pyplot as plt
import numpy as np
import pandas as pd

(_, axs) = plt.subplots(2, 1, sharex=True)

t0 = pd.date_range("2023-09-12 10:00", periods=48, freq="1H")
t1 = pd.date_range("2023-09-12 10:00", periods=12*48, freq="5Min")

x0 = pd.Series(
    index=t0,
    data=np.random.randn(48),
)
x1 = pd.Series(
    index=t1,
    data=np.random.randn(12*48),
)

x0.plot(ax=axs[0])
x1.plot(ax=axs[1])

Issue Description

When using subplots and sharing x axis, if a latter plot has a higher temporal resolution, the former plot gets emptied.

image

(Sorry, I checked the box that I've tested with the latest version of pandas but unfortunately I was able to test only 2.0.3 for now. I'll see if I can manage to test 2.1.0 some other day perhaps.)

Expected Behavior

Both plots should show data:

image

Installed Versions

INSTALLED VERSIONS

commit : 0f43794
python : 3.11.4.final.0
python-bits : 64
OS : Linux
OS-release : 6.3.3
Version : #1-NixOS SMP PREEMPT_DYNAMIC Wed May 17 12:02:08 UTC 2023
machine : x86_64
processor :
byteorder : little
LC_ALL : None
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 : 67.4.0.post0
pip : None
Cython : 0.29.36
pytest : 7.4.0
hypothesis : 6.68.2
sphinx : 5.3.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : 1.1
pymysql : None
psycopg2 : 2.9.5
jinja2 : 3.1.2
IPython : 8.11.0
pandas_datareader: None
bs4 : 4.12.2
bottleneck : None
brotli : 1.0.9
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.7.2
numba : None
numexpr : 2.8.4
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.1
snappy : None
sqlalchemy : 2.0.19
tables : 3.8.0
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2022.7
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team memberVisualizationplottingplotting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.