ax figure_obj add_subplot( , , ax plot( + ,ythis snippet first defines figure object using plt figure(we then get an axes object pointing to the first subplot generated using the statement figure_obj add_subplot( , , this statement is actually dividing the figure into two rows and two columns the last parameter (value is pointing to the first subplot in this grid the snippet is simply plotting the sine curve in the top-left subplot (identified as , , and another sine curve shifted by units on the -axis in the fourth subplot (identified as , , the output generated is shown in figure - figure - subplots using add_subplot method the second method for generating subplots is through the pyplot module directly the pyplot module exposes method subplots()which returns figure object and list of axes objecteach of which is pointing to subplot in the layout mentioned in the subplots(parameters this method is useful when we have an idea about how many subplots will be required the following snippet showcases the same figax_list plt subplots( , ,sharex=truefigsize=( )ynp sin(xax_list[ plot( ,yynp cos(xax_list[ plot( ,ythe statement plt subplots( , ,sharex=truedoes three things in one go it first of all generates figure object which is then divided into rows and column each ( two subplots in totalthe two subplots are returned in the form of list of axes objects the final and the third thing is the sharing of -axiswhich we achieve using the parameter sharex this sharing of -axis allows all subplots in this figure