Matplotlib: Sharing axes when having 3 graphs 2 at the left and 1 at the right
<p>I have following graph:
<a href="https://i.stack.imgur.com/Vqd85.png" rel="nofollow"><img src="https://i.stack.imgur.com/Vqd85.png" alt="enter image description here"></a></p>

<p>However, I want that graphs 221 and 223 share the same x axis. I have the following code:</p>

<pre><code>self.fig_part_1 = plt.figure()
self.plots_part_1 = [
  plt.subplot(221),
  plt.subplot(223),
  plt.subplot(122),
]
</code></pre>

<p>How can I achieve that? In the end I do not want the numbers of axis x in plot 221 to be shown.</p>

<p>Just use <code>plt.subplots</code> (different from <code>plt.subplot</code>) to define all your axes, with the option <code>sharex=True</code>:</p>

<pre><code>f, axes = plt.subplots(2,2, sharex=True)
plt.subplot(122)
plt.show()
</code></pre>

<p>Note that the second call with larger subplot array overlay the preceding one.</p>

<p><a href="https://i.stack.imgur.com/Y6SWD.png" rel="nofollow">Example</a> (could not display image due to reputation...)</p>

python matplotlib