Fig.add_subplot function in python

pyplot
add_subplot
python

#1

Hello,
Before plotting any distribution I have encountered the following code:

fig = plt.pyplot.figure()
ax = fig.add_subplot(111)

Can anyone explain what this mean?
Thanks


#2

Hey,
Here plt.pyplot.figure() creates the figure which contains all the plot elements and the with fig.add_subplot() u add a space where u have your histogram, graph etc. nd the subplot(111) represents thes ubplot grid parameters 111 represents 1 cross 1 first subplot .Similarly 322 represents 3 cross 2 2nd subplot
Thanks