I recently found the function subplots, which seems to be a more elegant way of setting up multiple subplots than subplot. However, I don\'t seem to be able to be able to chang
Yes you probably want to use the individual subplot instances.
As you've found, plt.ylabel
sets the ylabel of the last active plot. To change the parameters of an individual Axes
, i.e. subplot, you can use any one of the available methods. To change the ylabel, you can use axes[0].set_ylabel('plot 1')
.
pyplot
, or plt
as you've defined it, is a helper module for quickly accessing Axes
and Figure
methods without needing to store these objects in variables. As the documentation states:
[Pyplot p]rovides a MATLAB-like plotting framework.
You can still use this interface, but you will need to adjust which Axes
is the currently active Axes
. To do this, pyplot
has an axes(h) method, where h
is an instance of an Axes
. So in you're example, you would call plt.axes(axes[0])
to set the first subplot active, then plt.axes(axes[1])
to set the other.