Pandas plot method in connection with plt.fill_between causes Python to crash · Issue #12888 · pandas-dev/pandas (original) (raw)
When creating a plot with two y-axis, I run into the following problem. When plotting using the pd.Series.plot() method on the first y-axis and then applying ax.fill_between() Python crashes. If I use fill_between on the primary y-axis also the problem disappears.
Code Sample, a copy-pastable example if possible
npers = 100
index = pd.date_range(start='2000', freq='BM', periods=npers)
rel = pd.Series(index=index, data=np.random.randn(npers))
dd = pd.Series(index=index, data=np.random.randn(npers))
# this works
(w, h) = plt.figaspect(0.6)
fig = plt.figure(figsize=(w, h))
ax = fig.add_subplot(111)
# Not using pd.Series.plot()
ax.plot(rel.index, rel.values)
ax2 = ax.twinx()
ax2.fill_between(dd.index, dd.values)
# this crashes Python
(w, h) = plt.figaspect(0.6)
fig = plt.figure(figsize=(w, h))
ax = fig.add_subplot(111)
# Using pd.Series.plot()
ax = rel.plot(ax=ax)
ax2 = ax.twinx()
ax2.fill_between(dd.index, dd.values)
Expected Output
output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Windows
OS-release: 8.1
machine: AMD64
processor: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
pandas: 0.18.0
nose: 1.3.7
pip: 8.1.1
setuptools: 20.6.7
Cython: None
numpy: 1.11.0
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.0.0
sphinx: 1.3.1
patsy: 0.3.0
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: 3.1.1
numexpr: 2.3.1
matplotlib: 1.5.1
openpyxl: 1.8.5
xlrd: 0.9.3
xlwt: 1.0.0
xlsxwriter: None
lxml: 3.5.0
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 0.7.9
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.9.4