Subplot function can be used to plot multiple graphs in same canvas.
Case 1:- Create graph in same ROW
import matplotlib.pyplot as plt import numpy as np %matplotlib inline x = np.linspace(0, 5, 11) y = x ** 2 #Instantiate figure and axes object. #fig, ax = plt.subplots() # bydefualt on not passing any parameters in constructor, Just a figure and one subplot f, ax = plt.subplots(nrows=1, ncols=2) ax[0].plot(x, y) ax[0].set_title('Simple plot') ax[1].plot(y, x) ax[1].set_title('Simple plot')
Case 2:- Create graph in same Column
import matplotlib.pyplot as plt import numpy as np %matplotlib inline x = np.linspace(0, 5, 11) y = x ** 2 #Instantiate figure and axes object. #fig, ax = plt.subplots() # bydefualt on not passing any parameters in constructor, Just a figure and one subplot f, ax = plt.subplots(nrows=2, ncols=1) ax[0].plot(x, y) ax[0].set_title('Simple1 plot') ax[1].plot(y, x) ax[1].set_title('Simple2 plot')