Skip to content

Inconsistent plotting and crashing python on plotting with irregular time series #15074

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

Open
vfilimonov opened this issue Jan 6, 2017 · 1 comment
Labels

Comments

@vfilimonov
Copy link
Contributor

vfilimonov commented Jan 6, 2017

I believe it relates to the discussion in #15071, but I still think that reporting a test-case would be useful.

Synthetic example of two series

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

d1 = ['2015-01-05', '2015-01-06', '2015-01-07', '2015-01-08',
       '2015-01-09', '2015-01-12', '2015-01-13', '2015-01-14',
       '2015-01-15', '2015-01-16', '2015-01-19', '2015-01-20',
       '2015-01-21', '2015-01-22', '2015-01-23', '2015-01-26',
       '2015-01-27', '2015-01-28', '2015-01-29', '2015-01-30',
       '2015-02-02', '2015-02-03', '2015-02-04', '2015-02-05',
       '2015-02-06', '2015-02-09', '2015-02-10', '2015-02-11',
       '2015-02-12', '2015-02-13', '2015-02-16', '2015-02-17',
       '2015-02-25', '2015-02-26', '2015-02-27', '2015-03-02',
       '2015-03-03', '2015-03-04', '2015-03-05', '2015-03-06',
       '2015-03-09', '2015-03-10', '2015-03-11']
d2 = ['2015-01-31', '2015-02-28', '2015-03-31', '2015-04-30']

t1 = pd.Series(np.random.randn(len(d1)), index=pd.to_datetime(d1)).cumsum()+10
t2 = pd.Series(np.random.randn(len(d2)), index=pd.to_datetime(d2)).cumsum()+1

Problem description

Plotting it this way is done correctly:

t1.plot()
t2.plot()

image

If plotting in opposite order, it gives incorrect result:

t2.plot()
t1.plot()

image

Same problem if using secondary_y:

t2.plot()
t1.plot(secondary_y=True)

image

And if I try to plot it in the first order using secondary_y - it crashes the python (in IPython notebook - on the cell evaluation, in console - on plt.show()):

t1.plot()
t2.plot(secondary_y=True)

P.s. using plot(..., x_compat=True) resolves these issues.

Output of pd.show_versions()

The pandas version is 0.19.2+0.g825876c.dirty, which was installed as a default option by anaconda.

INSTALLED VERSIONS ------------------ commit: None python: 2.7.12.final.0 python-bits: 64 OS: Windows OS-release: 7 machine: AMD64 processor: Intel64 Family 6 Model 63 Stepping 0, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None

pandas: 0.19.2+0.g825876c.dirty
nose: 1.3.7
pip: 8.1.2
setuptools: 27.2.0
Cython: 0.25.1
numpy: 1.11.2
scipy: 0.18.1
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.4.8
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: 1.1.0
tables: 3.2.2
numexpr: 2.6.1
matplotlib: 1.5.1
openpyxl: 2.4.0
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.3
lxml: 3.6.0
bs4: 4.5.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: 1.1.3
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.43.0
pandas_datareader: 0.2.0

@jong1prk
Copy link

sorry for late comment, but I just check what you said. Can you explain the reason why that results happens? I don't understand why the result changes by just changing the order of codes.

@jbrockmendel jbrockmendel added the Visualization plotting label Aug 1, 2018
@mroeschke mroeschke added the Bug label May 8, 2021
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