What’s New in Matplotlib 3.1
A new method for creating legends for scatter plots has been introduced. Now, provides a method to obtain the handles and labels for a scatter plot in an automated way. This makes creating a legend for a scatter plot as easy as An example can be found in Automated legend creation.
Source: matplotlib.org