Python Matplotlib.pyplot.legend() Syntax

Syntax: matplotlib.pyplot.legend([“blue”, “green”], bbox_to_anchor=(0.75, 1.15), ncol=2)

Attributes:

  • shadow: [None or bool] Whether to draw a shadow behind the legend.It’s Default value is None.
  • markerscale: [None or int or float] The relative size of legend markers compared with the originally drawn ones.The Default is None.
  • numpoints: [None or int] The number of marker points in the legend when creating a legend entry for a Line2D (line).The Default is None.
  • fontsize: The font size of the legend.If the value is numeric the size will be the absolute font size in points.
  • facecolor: [None or “inherit” or color] The legend’s background color.
  • edgecolor: [None or “inherit” or color] The legend’s background patch edge color.

Matplotlib.pyplot.legend() in Python

A legend is an area describing the elements of the graph. In the Matplotlib library, there’s a function called legend() which is used to place a legend on the axes. In this article, we will learn about the Matplotlib Legends.

Similar Reads

Python Matplotlib.pyplot.legend() Syntax

Syntax: matplotlib.pyplot.legend([“blue”, “green”], bbox_to_anchor=(0.75, 1.15), ncol=2) Attributes: shadow: [None or bool] Whether to draw a shadow behind the legend.It’s Default value is None. markerscale: [None or int or float] The relative size of legend markers compared with the originally drawn ones.The Default is None. numpoints: [None or int] The number of marker points in the legend when creating a legend entry for a Line2D (line).The Default is None. fontsize: The font size of the legend.If the value is numeric the size will be the absolute font size in points. facecolor: [None or “inherit” or color] The legend’s background color. edgecolor: [None or “inherit” or color] The legend’s background patch edge color....

Matplotlib.pyplot.legend() in Python

Matplotlib.pyplot.legend() function is a utility given in the Matplotlib library for Python that gives a way to label and differentiate between multiple plots in the same figure...

Python Matplotlib legend() Function Examples

Below are some examples that can see the Matplotlib interactive mode setup using Matplotlib.pyplot.legend() in Python:...