Create Multiple Subplots using Matplotlib Subplot in Python

Hi, everyone in the post we are going to learn how we can Create Multiple Subplots using Matplotlib Subplot in Python.

So Let’s start the learning part:-

Python provides us a special module to visualize the data set Matplotlib.

If you don’t have this module the pip it by using pip install matplotlib.

In this module, we have special function subplots by which we can create multiple plots at a time.

There are two parameters that we are going to pass in subplot nrows and ncols.

Basically, subplot is like a matrix in which at i,j a particular plot is present

So let’s have a look at the code:-

import matplotlib.pyplot as plt
import numpy as np

fig, axis=plt.subplots(nrows=2,ncols=2)
axis[0,0].plot(x,y,label="Sine Graph",color="Red")
axis[0,1].plot(x,z,label="Cosine Graph",color="Blue")
axis[1,0].plot(x,w,label="Tan Graph",color="Green")
axis[1,1].plot(x,q,label="Normal Strainmgh Line",color="purple")
axis[0,0].set_xlabel("X AXIS")
axis[0,0].set_ylabel("Y AXIS")
axis[0,1].set_xlabel("X AXIS")
axis[0,1].set_ylabel("Y AXIS")
axis[1,0].set_xlabel("X AXIS")
axis[1,0].set_ylabel("Y AXIS")
axis[1,1].set_xlabel("X AXIS")
axis[1,1].set_ylabel("Y AXIS")

Here is the output:-

Create Multiple Subplots using Matplotlib Subplot in Python

Thank You.

Also read: How To Plot Heatmap in Python

Chess Board Using MatPlotLib Python

Leave a Reply

Your email address will not be published. Required fields are marked *