Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Blank axes when mixing pandas- and matplotlib-style plots in matplotlib>=3.4.0 #45320

Open
2 of 3 tasks
kandersolar opened this issue Jan 11, 2022 · 2 comments
Open
2 of 3 tasks
Labels

Comments

@kandersolar
Copy link
Contributor

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 master branch of pandas.

Reproducible Example

import matplotlib
import matplotlib.pyplot as plt
import pandas as pd

tz = 'Etc/GMT+5'  # change to None
freq = 'h'  # change to 'd'
times = pd.date_range('2019-01-01', freq=freq, periods=3, tz=tz)
series = pd.Series(range(len(times)), index=times)

fig, ax = plt.subplots()
series.plot(ax=ax)
ax.errorbar([times[1]], [1], yerr=[[1], [2]], c='k')
plt.title(f"freq='{freq}' tz={tz}\n"
          f'matplotlib=={matplotlib.__version__} pandas=={pd.__version__}')

Issue Description

For timeseries data, mixed pandas-style (Series.plot(ax=ax)) and pyplot-style (ax.plot()) plotting has different behavior starting in matplotlib==3.4.0. I can't make sense of what's going on, but the difference depends on whether the Series is tz-localized and the frequency of the data. Here are some comparisons using the MRE:

Description matplotlib==3.3.4 matplotlib==3.4.0
Axes show no lines at all h_Etc_GMT+5_3 3 4 h_Etc_GMT+5_3 4 0
Axes show line from Series.plot(), but not the ax.errorbar h_None_3 3 4 h_None_3 4 0
Both lines display, though the error bar is timeshifted d_Etc_GMT+5_3 3 4 d_Etc_GMT+5_3 4 0
No apparent difference d_None_3 3 4 d_None_3 4 0

Expected Behavior

I suppose I expect to be able to mix and match pandas- and matplotlib-style plotting calls like I can with matplotlib 3.3.4.

Installed Versions

INSTALLED VERSIONS

commit : 66e3805
python : 3.7.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None

pandas : 1.3.5
numpy : 1.19.5
pytz : 2019.3
dateutil : 2.8.1
pip : 21.3.1
setuptools : 50.3.0
Cython : 0.29.26
pytest : 6.2.3
hypothesis : None
sphinx : 3.2.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.31.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.4.0
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.5.4
sqlalchemy : None
tables : 3.6.1
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.53.1

@kandersolar kandersolar added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 11, 2022
@mroeschke mroeschke added Visualization plotting and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 14, 2022
@jorisvandenbossche
Copy link
Member

@kanderso-nrel thanks for the report! I can confirm this still happens on the main branch of pandas as well, and also with the latest matplotlib 3.5.1

cc @QuLogic in case you are aware of similar issues / reports at the matplotlib side, or know what might have caused this (didn't yet further investigate it myself)

@QuLogic
Copy link
Contributor

QuLogic commented Feb 8, 2022

Possibly the Pandas date converters auto-registration? 3.3 changed the epoch of dates, I don't know if anything was in 3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants