-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Open
Labels
Description
Environment is Anaconda 2.3, using python 2.7.10. Pandas version 0.16.2.
Here's the code to reproduce this problem in IPython Notebook 3.2, only df['col3']
is plotted.
When sharing an axis the last plot() seems to override whatever was plotted before. Only the last plotted item is shown in figure.
import pandas as pd
import bumpy as np
import matplotlib.pyplot as plt
%matplotlib inline
drange = pd.date_range(start='2015-07-01', end='2015-07-10', freq='D')
df = pd.DataFrame(data=np.random.random_sample((10, 3)), index=drange, columns=['col1', 'col2', 'col3'])
fig, ax = plt.subplots()
plt.hold(True) # when the index is just integer type, this will make it work.
df[['col1', 'col2']].plot(kind='bar', ax=ax, stacked=True)
df[['col3']].plot(ax=ax, color='r', marker='o', ls='-', alpha=.7) # This overrides the previous plot
# if you use this line below instead of the line above, both bars and lines will show up:
#ax.plot(df[['col3']], color='r', marker='o', ls='-', alpha=.7)
ax.grid(True)
ax.legend(loc='best')
ian-contiamo, thejonan, msitt and mbells