Matplotlib legend in subplotIn this tutorial, we will learn how Matplotlib can be used to include legends in subplots. The legend can be added after creating the plot using the legend() function. Syntax:The syntax for legend in subplot is: where, loc is used for location. Approaches:Following are the approaches we will use for displaying legend in the subplot in Matplotlib:
Example 1:In this example, we will plot the scatter graph using subplot of log10 and exponential: Output ![]() Example 2:In this example, we will plot the scatter graph using subplot of sine and cos: Output ![]() Example 3:In this example, we will plot the scatter graph using subplot of (y = x^2) and (y = x^3): Output ![]() ConclusionIn this tutorial, we have discussed how to use legend in the subplot of matplotlib graphs using different methods. |
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week