Matplotlib legend in subplot
In 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.
The syntax for legend in subplot is:
where, loc is used for location.
Following are the approaches we will use for displaying legend in the subplot in Matplotlib:
In this example, we will plot the scatter graph using subplot of log10 and exponential:
In this example, we will plot the scatter graph using subplot of sine and cos:
In this example, we will plot the scatter graph using subplot of (y = x^2) and (y = x^3):
In 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