![]() Plt.legend(, fontsize="20", loc ="upper left") ![]() Here's another code example with the fontsize parameter included: import matplotlib.pyplot as plt Plt.show() matplotlib graph with default legend font size Here's what the default legend font size looks like: import matplotlib.pyplot as plt You can change the font size of a Matplotlib legend by specifying a font size value for the fontsize parameter. How To Change Legend Font Size in Matplotlib Using the fontsize Parameter ![]() You can change the position of the legend using the following values of the loc parameter: This makes it easier for anyone viewing the graph to know that the blue line denotes age while the orange line denotes number in the graph. In the graph above, we've used the legend function to describe each line in the plot. Plt.show() two line graph with different legend descriptions Here's an example: import matplotlib.pyplot as plt With the legend function, you can assign different descriptions to each line of a graph. A description of "Data" was assigned to the legend, and was placed in the upper right corner of the graph using the upper right value of the loc parameter. In the graph above, we described the plot using a legend. Plt.show() matplotlib graph with a legend You'll then learn how to change the font size of a Matplotlib legend using:Ī legend is a Matplotlib function used to describe elements that make up a graph.Ĭonsider the graph below: import matplotlib.pyplot as plt In this article, you'll learn what a legend is in Matplotlib, and how to use some of its parameters to make your plots more relatable. You can modify different properties of a plot - color, size, label, title and so on - when working with Matplotlib.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |