title: plotting imshow and line plot together in python
body: <p>Okay I'm totally stuck with a Python problem. I think describing the problem in too much detail is confusing, so I will summarise the problem and then show the code I have.</p>
  
  <p>I have created an imshow plot, over the top of which, I would like to plot a regular line plot. The Y axis is different, which is fine, but the X axes should be the same for both.</p>
  
  <p>It almost works, apart from the scaling:</p>
  
  <pre><code>fig = plt.figure()
  ax1 = fig.add_subplot(111)
  ax1.set_xlabel('MJD',fontsize=14)
  ax1.set_ylabel('Bin Number',fontsize=14)
  mjdaxis=np.linspace(0,bad_removed_mjd.shape[0]-1,20).astype('int')
  ax1.set_xticks(mjdaxis,[int(np.floor(bad_removed_mjd[i])) for i in mjdaxis])
  ax1.imshow(residuals, aspect="auto")
  
  ax2 = ax1.twinx()
  ax2.set_ylabel('Pdot (s-2)',fontsize=14)
  ax2.plot(pdot[8:,0],pdot[8:,1])
  
  plt.show()
  </code></pre>
  
  <p>Now what happens is that the imshow plot gets squashed between values 0-60 or so on the x axis. This is because they are now getting plotted by their index number 0,1,2.... I need their x axis values to correspond to the value in the list 'bad_mjd_removed' 55304, 55365, 55401.... This works fine when I just have the imshow plot on its own.</p>
  
  <p>Here are pictures of the imshow plot on its own, and then when I try to add the line plot over it:</p>
  
  <p><img src="https://i.imgur.com/koKIP.png" alt="plot with imshow only">
  <img src="https://i.imgur.com/7F8Vq.png" alt="plot with imshow and line plot"></p>
  
  <p>On the second plot, the thin line at around 0 on the x axis is the whole of picture 1 squeezed inbetween 0 and 60.</p>
  
  <p>I would be very grateful of any help on this problem. Thank you.</p>