title: Each row sharey individually?
body: <p>I have a two-by-two plot that I am creating dynamically. In the first row I want to plot density functions, in the second row CDFs. I want </p>
  
  <ul>
  <li>each of the columns to share x</li>
  <li>each of the rows to share y</li>
  </ul>
  
  <p>That is, two objects aligned vertically have the same x-axis, and two plots aligned horizontally have the same y-axis.</p>
  
  <p>However, <code>sharex</code> and <code>sharey</code> force them to be the same for all of the subplots. How can I fix this sort of axes sharing? I understand that I could be manually giving each axes a share partner, but that wouldn't work with the generic structure that follows: </p>
  
  <pre><code>fig, axes = plt.subplots(nrows=2, ncols=2, sharex=True)
  for i, lam in enumerate(lams):
      axesNow = [axs[i] for axs in axes]  # pick the ith column from axes
      for i, Param.p in enumerate(pp):
          axesNow[0].plot(somethingWithPDF)
          axesNow[1].plot(somethingWithCDF)
  
  for ax in axes.flatten(): ax.legend()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/7SxTV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7SxTV.png" alt="enter image description here"></a></p>