I have a time series of financial data in a Pandas DataFrame:
Date Close Volume
2003-09-01 8.24890 54344
2003-09-02 8.23245 76655
2003-09-03 8.22710 87655
I would like to plot the price (Close) on the left axis and the volume on the right axis. The latter should be a histogram, while the former should be a normal line-graph.
I have the following code:
fig, ax = plt.subplots(figsize=(18, 10))
ax2 = ax.twinx()
df[instrument]['Close'].plot(ax=ax, style='b-')
plt.ylabel('Rate')
df[instrument]['Volume'].hist(ax=ax2)
plt.ylabel('Volume')
plt.xlabel('Date')
plt.plot()
The price comes up fine. The volume does not show up on the right axis. However, I do get some numbers on the right axis, but no histogram. How can I fix this?
Here is an example of what I would like to achieve:
Thanks in advance