![]() |
VOOZH | about |
A legend is basically an area in the plot which describes the elements present in the graph. Matplotlib provides an inbuilt method named legend() for this purpose. The syntax of the method is below :
Example: Adding Simple legend
Output:
👁 ImageTo create a legend with a color box, patches are used provided by the matplotlib.patches module. A patch nothing but a 2D artist with face color and edge color. Below is a simple example of this:
Example 1:
Output:
👁 ImageExample 2: