What is the difference between drawing plots using plot, axes or figure in matplotlib? : <p>I'm kind of confused what is going at the backend when I draw plots in matplotlib, tbh, I'm not clear with the hierarchy of plot, axes and figure. I read the documentation and it was helpful but I'm still confused...</p>

<p>The below code draws the same plot in three different ways - </p>

<pre><code>#creating the arrays for testing
x = np.arange(1, 100)
y = np.sqrt(x)
#1st way
plt.plot(x, y)
#2nd way
ax = plt.subplot()
ax.plot(x, y)
#3rd way
figure = plt.figure()
new_plot = figure.add_subplot(111)
new_plot.plot(x, y)
</code></pre>

<p>Now my question is -</p>

<ol>
<li><p>What is the difference between all the three, I mean what is going under the hood when any of the 3 methods are called? </p></li>
<li><p>Which method should be used when and what are the pros and cons of using any on those?  </p></li>
</ol>
