spacepy.plot.shared_ylabel(axes, txt, *args, **kwargs)[source]

Create a ylabel that spans several subplots

Useful for a multi-panel plot where several subplots have the same units/quantities on the y axis.


The Axes objects (i.e. subplots) which should share a single label


The label to place in the middle of all the axes objects.


The Text object for the label.

Other Parameters:
Additional arguments and keywords are passed through to


This function can be fairly fragile and should only be used for fairly simple layouts, e.g., a one-column multi-row plot stack.

The label is associated with the bottommost subplot in axes.


>>> import spacepy.plot.utils
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> #Make three stacked subplots
>>> ax0 = fig.add_subplot(311)
>>> ax1 = fig.add_subplot(312)
>>> ax2 = fig.add_subplot(313)
>>> ax0.plot([1, 2, 3], [1, 2, 1]) #just make some lines
[<matplotlib.lines.Line2D object at 0x0000000>]
>>> ax1.plot([1, 2, 3], [1, 2, 1])
[<matplotlib.lines.Line2D object at 0x0000000>]
>>> ax2.plot([1, 2, 3], [1, 2, 1])
[<matplotlib.lines.Line2D object at 0x0000000>]
>>> #Create a green label across all three axes
>>> spacepy.plot.utils.shared_ylabel([ax0, ax1, ax2],
... 'this is a very long label that spans all three axes', color='g')