lmiguelvargasf lmiguelvargasf - 5 months ago 34
Python Question

Matplotlib: Sharing axes when having 3 graphs 2 at the left and 1 at the right

I have following graph:
enter image description here

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

self.fig_part_1 = plt.figure()
self.plots_part_1 = [

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


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

f, axes = plt.subplots(2,2, sharex=True)

Note that the second call with larger subplot array overlay the preceding one.

Example (could not display image due to reputation...)