Misaligned shared axes between timeseries plots of different frequency. #11574
Open
Description
Observed in pandas 0.17.0 and the current development version (d78266e).
It seems to me that pandas fail to align timeseries plots with different frequency unit (or no frequency) when they are drawn on different axes with one shared axis. The issue does not occur if the two timeseries are plotted on the same axes.
Example:
"""Shared axes between timeseries plots of different frequency."""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
pd.show_versions()
# prepare a random time series
t = pd.date_range('1/1/2000', periods=1000)
x = np.random.randn(1000)
ts = pd.Series(x, index=t).cumsum()
# initialize figure
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, sharex=True)
# plot original and resampled timeseries
ts.plot(ax=ax1) # works as expected
ts.resample('30D').plot(ax=ax2) # works as expected
ts.resample('1M').plot(ax=ax3) # seem to mess up x axis
# show
plt.show()
After the third series is drawn, the first two appear shifted out of the frame to wrong x-coordinates.
Version info:
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.3.final.0
python-bits: 64
OS: Linux
OS-release: 3.2.0-4-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.17.0+159.gd78266e
nose: 1.3.7
pip: 7.1.2
setuptools: 14.3.1
Cython: 0.22
numpy: 1.10.1
scipy: 0.16.0
statsmodels: None
IPython: 0.13.1
sphinx: 1.3.1
patsy: None
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: 0.7.4
apiclient: None
sqlalchemy: 0.7.8
pymysql: None
psycopg2: 2.4.5 (dt dec mx pq3 ext)
Thanks!