I have the following dataframe I want to plot. I'm trying to have 2 subplots, one of them with two plots on it (with different y axes and sharing the x)
size = (20,10)
fig = plt.figure(figsize=size)
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212)
ax3 = ax2.twinx()
# the dataframe is obtained by other means, and has the following format:
Date col1 col2 col3 col4
2017-06-30 7813.9291 0.0000 0.0000 0.000000
2017-07-31 8222.1428 0.0000 0.0000 4.964809
2017-08-31 7010.1959 0.0000 0.0000 -17.288346
2017-09-30 5878.8063 0.0000 0.0000 -19.245227
.
.
.
df.iloc[:,0:3].plot.bar(figsize = size, ax = ax3)
df.iloc[:,-1].plot(figsize = size, ax = ax2)
The other plot with only one plot in the figure(in ax1) does not give any problems, so I won't post it here.
The problem is, when I run this code, only one the plots remains in the figure, (the last line), and the other just disappears. If I switch the order of the last two lines, then the other plot remains.
Any ideas why is this happening?
EDIT: I'm using a jupyter notebook, with pandas 0.24 and python 3.7
col2is zero so you don't see any bars forcol2. The only bars will come fromcol1df.iloc[:,0:3].plot.bar(ax=ax2, secondary_y=True)and thendf.iloc[:,-1].plot(ax=ax2)Date?