figure - example to show line_width and shorthand notation legends graph legend is key that helps us map color/shape or other attributes to different attributes being visualized by the plot though in most cases matplotlib does wonderful job at preparing and showing the legendsthere are times when we require finer level of control the legend of plot can be controlled using the legend(functionavailable through the pyplot module directly we can set the locationsizeand other formatting attributes through this function the following example shows the legend being placed in the best possible location plt plot( , ,' ',label=' = ^ 'plt plot( , ,' :',label=' = 'plt legend(loc="best"plt title('legend sample'