title: How can I create a sub plot in Matplotlib with one of the subplots showing xaxis values on y-ticks?
body: <p>I am trying to create a subplot similar to the one shown below. I just sketched it up to give an idea of what kind of plot I am trying to build. Also, I created some dataset (see below) to reproduce my real dataframe. As you can see, it would have been much easier for me to build the subplots if there was no depth axis. The depth column is actually an xaxis, but I don't want to make a scatter plot (date vs depth) like other subplots, but instead I want to plot it in the same way as in the sample plot on the yaxis ticks. The date column should be shared among all subplots, so I can zoom in/out all the plots simultaneously. I am able to create simple subplots, but I couldn't get my head around how to add the depth column as shown here.</p>
  <p><a href="https://i.stack.imgur.com/5tfAc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5tfAc.png" alt="enter image description here" /></a></p>
  <pre><code> date   depth   temp    pressure
  01-01-22    1200    50  1200
  02-01-22    1250    52  1250
  03-01-22    1350    55  1300
  04-01-22    1355    59  1220
  05-01-22    1360    56  1200
  06-01-22    1370    52  1230
  </code></pre>
  <p>additional info - I am using this code, and please see the plot below. It seems ok on the plot, but it is actually not doing what I needed. To show why it is not doing what I need, I plotted Datetime vs Depth (similar plot) on the next axis. As you can see, for instance, the depth 1000m should appear at a different Datetime value, whereas on Depth yticks 1000m appears at a later date. I think this Depth values on 1st axis yticks are evenly distributed. You can also see on the sketch, the depth values are not evenly distributed. I can't seem to figure out how to get it working the way I need it?</p>
  <pre><code>    fig, axes = plt.subplots(figsize=(10,10), sharey=True)
      
      gs = gridspec.GridSpec(1, 3, width_ratios=[5,5,5])
      
      ax1 = plt.subplot(gs[0])
      ax2 = plt.subplot(gs[1])
      ax3 = plt.subplot(gs[1])
      ax4 = plt.subplot(gs[1])
      ax5 = plt.subplot(gs[2])
      
      ax1.get_shared_y_axes().join(ax1,ax2,ax3,ax4,ax5)
      
      ax1.xaxis.set_visible(False)
          
      ax1.set_ylim(df['DATE_TIME'].min(), df['DATE_TIME'].max())
      ax1.annotate('Datetime', xy=(0, 1.02), xycoords=&quot;axes fraction&quot;, fontsize=12, ha=&quot;center&quot;) 
  fraction&quot;, fontsize=&quot;large&quot;, ha=&quot;center&quot;) 
      
      ax3 = ax1.twinx()
      spine_distance = 0.7
      ax3.spines[&quot;right&quot;].set_position((&quot;axes&quot;, spine_distance)) 
      ax3.tick_params(axis=&quot;y&quot;, direction=&quot;in&quot;, pad=-30)
      ax3.set_ylim(df['Depth (m)'].min(), df['Depth (m)'].max())
      ax3.annotate('Depth', xy=(spine_distance, 1.02), `xycoords=&quot;axes,fraction&quot;, fontsize=&quot;large&quot;, ha=&quot;center&quot;)`
      
      ax4.plot(df['Depth (m)'],df['DATE_TIME'], color='black', linewidth=0.9)
      ax4.annotate('Depth m', xy=(spine_distance, 1.02), xycoords=&quot;axes fraction&quot;, fontsize=&quot;large&quot;, ha=&quot;center&quot;)
      
      ax5.plot(df['temp'],df['DATE_TIME'], color='blue', linewidth=0.9)
      ax5.annotate('Temp', xy=(spine_distance, 1.02), xycoords=&quot;axes fraction&quot;, fontsize=&quot;large&quot;, ha=&quot;center&quot;)
      
      for ax in [ax4,ax5]:
          plt.setp(ax.get_yticklabels(), visible=False)
      plt.show()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/IyFKr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IyFKr.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/KsAD0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KsAD0.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/VGAVX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VGAVX.png" alt="enter image description here" /></a></p>