title: Howto force Pandas and native matplotlib to share axis
body: <p>I folks,</p>
  
  <p>Consider the following example</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import pandas as pd
  import numpy as np
  
  fig, (ax1,ax2) = plt.subplots(2,1)
  dates = pd.date_range("2018-01-01","2019-01-01",freq = "1d")
  x = pd.DataFrame(index = dates, data = np.linspace(0,1,len(dates)) )
  x.plot(ax=ax1)
  y = np.random.random([len(dates),100]) * x.values 
  ax2.pcolormesh(range(len(x)), np.linspace(-1,1,100), y.T)
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mkYqG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mkYqG.png" alt="Plot"></a></p>
  
  <p>At this point, I would like the both axis (ax1,ax2) to share the x-axis, i.e. displaying proper pandas dates on the second axis. <code>sharex=True</code> does not seem to work. How can I achieve that? I tried different possibilities which did not work out.</p>
  
  <p>Edit: Since the pandas date formatting is superior to the native matplotlib formatting, please provide me with a solution where pandas date formatting is used (for instance, zooming with an interactive environment works much better with pandas date formatting). Thanks You!</p>