title: Combine line and histogram in Matplotlib
body: <p>I have a time series of financial data in a Pandas DataFrame:</p>
  
  <pre><code>Date  Close Volume                              
  2003-09-01 8.24890  54344
  2003-09-02 8.23245  76655
  2003-09-03 8.22710  87655
  </code></pre>
  
  <p>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.</p>
  
  <p>I have the following code:</p>
  
  <pre><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()
  </code></pre>
  
  <p>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?</p>
  
  <p>Here is an example of what I would like to achieve:
  <a href="https://i.stack.imgur.com/MueQ2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MueQ2.jpg" alt="enter image description here"></a></p>
  
  <p>Thanks in advance</p>