Quantcast
Viewing all articles
Browse latest Browse all 11

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

All of the previous answers are way over my head, at this state of my coding journey, so I just added another Matplotlib aspect called patches:

import matplotlib.patches as mpatchesfirst_leg = mpatches.Patch(color='red', label='1st plot')second_leg = mpatches.Patch(color='blue', label='2nd plot')thrid_leg = mpatches.Patch(color='green', label='3rd plot')plt.legend(handles=[first_leg ,second_leg ,thrid_leg ])

The patches aspect put all the data i needed on my final plot (it was a line plot that combined three different line plots all in the same cell in Jupyter Notebook).

Result

(I changed the names form what I named my own legend.)

Image may be NSFW.
Clik here to view.
I changed the names form what i named my own


Viewing all articles
Browse latest Browse all 11

Trending Articles