Skip to content

Make bar plot on secondary axis, the line plot on the primary axis wont show. #4387

@tesla1060

Description

@tesla1060

Following issue #3598,

df = pd.DataFrame(np.random.uniform(size=10).reshape(5,2),columns=['A','B'])
df['A'] = df['A'] * 100
df.A.plot()
df.B.plot(kind='bar',secondary_y=True)
plt.show()

This gives the right plot, with A plotted as line in the primary axis, and B is plotted as bar in the secondary axis.

But if I index the dataframe by datetime

df = pd.DataFrame(np.random.uniform(size=10).reshape(5,2),columns=['A','B'])
df = df.set_index(pd.date_range('20130101',periods=5))
df['A'] = df['A'] * 100
df.A.plot()
df.B.plot(kind='bar',secondary_y=True)
plt.show()

This wont plot A as line in the primary axis, only the B as bar in the secondary axis. Not sure why.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions