One ylabel for two subplots using Python Matplotlib.pyplot


The result is:

One ylabel for two subplots using Python Matplotlib.pyplot

This page shows how to write one label on two subplots using python and matplotlib.pyplot. By set label_coords of the ylabel, you can move the position of the ylabel.
In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
In [2]:
plt.figure(figsize=(3, 2))
ax1 = plt.subplot(2, 1, 1)
ax2 = plt.subplot(2, 1, 2)
ax1.set_ylabel('y Axis')
plt.setp(ax1.get_xticklabels(), visible=False)
ax1.yaxis.set_label_coords(-0.16, -0.1)
plt.savefig('one_ylabel.png', bbox_inches='tight', dpi=150)
One ylabel for two subplots using Python Matplotlib.pyplot