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. |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/263297.html