



I would also suggest taking a look at fig.suptitle(), consider using a brief title per subplot ("Winter") or not at all since the legend already includes this. Python3 import numpy as np import matplotlib.pyplot as plt xnp.array ( 1, 2, 3, 4, 5) fig, ax plt.subplots (2, 2) ax 0, 0.plot (x, x) ax 0, 1.plot (x, x2) ax 1, 0.plot (x, xx) ax 1, 1. # set up labels, limits, gridlines, legendsĪx.set_ylabel('Temperature anomaly (Celsius)') We use .settitle (label) method to set title (string label) for the current subplot Axes. # Plot dataĪx11.set_title('Anomaly in temperature during winters 1953-2016')Īx12.set_title('Anomaly in temperature during springs 1953-2016')Īx21.set_title('Anomaly in temperature during summers 1953-2016')Īx22.set_title('Anomaly in temperature during falls 1953-2016') Or more simply/more generally, just iterate over all of the handles at the end: for ax in axes.flat:ĮDIT: a more comprehensive solution to show construction of the subplots in two parts - things that differ vs things that are consistent. If you use the per-subplot handles, you will produce the desired result of a legend in each subfigure -Įither change your calls to plt.legend() after the plot to ax11.legend() So the thing is I want the legend, axis titles and plot title to each subplot. It all also gives me the error: No handles with labels found to put in legend. Plt.title('Anomaly in temperature during falls 1953-2016') Plt.title('Anomaly in temperature during summers 1953-2016') Plt.title('Anomaly in temperature during springs 1953-2016') Plt.ylabel('Temperature anomaly (Celsius)') Plt.title('Anomaly in temperature during winters 1953-2016') #Create subplotįig, axes = plt.subplots(nrows=2, ncols=2, figsize=(12,8)) What am I doing wrong here? Tried reading through all the previous answers to the same problem but could not figure out what the problem is, why does the legend etc only go on the last subplot? Probably a really simple thing I'm missing here.
