Skip to content

BUG:New epoch in matplotlib 3.3 causes plotting issues #35320

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

Closed
3 tasks done
selasley opened this issue Jul 17, 2020 · 3 comments
Closed
3 tasks done

BUG:New epoch in matplotlib 3.3 causes plotting issues #35320

selasley opened this issue Jul 17, 2020 · 3 comments
Labels

Comments

@selasley
Copy link
Contributor

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import pandas as pd
import matplotlib.pyplot as plt

ndx = pd.to_datetime(['2020-07-1 04:01:34', '2020-07-2 04:03:33', '2020-07-3 04:05:33',
                      '2020-07-4 04:07:35', '2020-07-5 04:09:35']) 
df = pd.DataFrame(index=ndx, data={'Vsw': [389.4, 388.5, 384.5, 384.7, 386.6]})
print(df.info())
ax1 = df['Vsw'].plot(xlim=['2020-7-1', '2020-7-6'])
print(ax1.get_xlim(), '\n\n\n')
plt.show()

# plot without specifying x limits
ax2 = df['Vsw'].plot()
print(ax2.get_xlim(), '\n\n\n')
plt.show()

# plot from a DataFrame with a pd.date_range index
df = pd.DataFrame(index=pd.date_range('2020-7-1', '2020-7-5', freq='D'),
                  data={'Vsw': [389.4, 388.5, 384.5, 384.7, 386.6]})
print(df.info())
ax3 = df['Vsw'].plot(xlim=['2020-7-1', '2020-7-6'])
print(ax3.get_xlim())
plt.show()

Problem description

See https://matplotlib.org/3.3.0/users/whats_new.html#dates-use-a-modern-epoch

The first plot is blank. get_xlim returns (18444.0, 18449.0) The second plot contains the values being plotted and get_xlim returns (737606.9674762732, 737611.3736001157). The third plot shows the plotted values and get_xlim returns (18444.0, 18449.0).

If the epoch is set to the old epoch value with
import matplotlib.dates as mpld
mpld.set_epoch('0000-12-31T00:00:00')
all three plots show the plotted values. get_xlim returns (737607.0, 737612.0) for the first plot, (737606.9674762732, 737611.3736001157) for the second and (18444.0, 18449.0) for the third.

Expected Output

The three plots should show the values being plotted whether or not xlim is specified in the plot() command or the DatetimeIndex has a Freq value

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 6509028
python : 3.8.4.final.0
python-bits : 64
OS : Darwin
OS-release : 19.6.0
Version : Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.0.dev0+2131.g650902866
numpy : 1.19.0
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 47.3.1
Cython : 0.29.20
pytest : None
hypothesis : None
sphinx : 3.1.1
blosc : None
feather : None
xlsxwriter : 1.2.9
lxml.etree : 4.5.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: None
bs4 : 4.9.1
bottleneck : 1.3.2
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.0
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.0
sqlalchemy : 1.3.18
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
numba : 0.50.1

@selasley selasley added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 17, 2020
@igavronski
Copy link

Duplicate of #34850

@igavronski
Copy link

@TomAugspurger
Copy link
Contributor

Closing in favor of #34850

@bashtage bashtage removed the Needs Triage Issue that has not been reviewed by a pandas team member label Aug 21, 2020
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