The most common way to make a legend is to define the label parameter for each of the plots and finally call pltlegend.
Example plt legend. MyPlot pyplotplot pyplotgcalegend. Affiche la légende mais en fait cest équivalent aux 2 étapes suivantes qui peuvent être décomposées. Plot 1 2 3 ax.
It is still quite simple to add a second legend or third or fourth to an axes. Pltlegend sur son propre ne rien afficher à la console mais le tracé a maintenant une légende auto-généré à partir du tracé de données. Pltlegendbbox_to_anchor1 1 bbox_transformpltgcftransFigure More examples of custom legend.
However sometimes you might want to construct the legend on your own. Plot legend in python. Note that you can click on legend items to hide or to select with a double click a specific trace.
Handles labels pyplotgca. Run from timeSeriesPredictpy fig pltfigurefacecolorwhite ax figadd_subplot111 axplotY labelY Print the predictions in its respective series-length for i j in enumerateY_hat. Put legend inside plot matplotlib.
Import matplotlibpyplot as plt pltstyleuseclassic In 2. One legend is for the lines and the other is for the markers. The example below explores a vector field using several traces.
Plot 6 4 2 label Second Data place legend above plot plt. In the example here we plot two lines then plot markers on their respective maxima and minima. Legend A simple line.