Quantcast
Viewing all articles
Browse latest Browse all 11

Answer by heiner for How do I make a single legend for many subplots?

To build on top of gboffi's andBen Usman's answer:

In a situation where one has different lines in different subplots with the same color and label, one can do something along the lines of:

labels_handles = {  label: handle for ax in fig.axes for handle, label in zip(*ax.get_legend_handles_labels())}fig.legend(  labels_handles.values(),  labels_handles.keys(),  loc = "upper center",  bbox_to_anchor = (0.5, 0),  bbox_transform = plt.gcf().transFigure,)

Viewing all articles
Browse latest Browse all 11

Trending Articles