You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
IIRC we put additional state on the axes object for timeseries plots, which presumably isn't copied over correctly when the axis is twinned. I'm not sure the best way to handle it.
Easiest workaround for now is either what you did first, or use the x_compat=Trueparameter in the first call to rel.plot(...). That gives me a correct plot. Or you can change your second plot to ax2 = dd.plot(ax=ax, secondary_y=True) and then fill_between on that.
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
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
The text was updated successfully, but these errors were encountered: