title: Why matplotlib does not show the scatter plot in a second cell of a Jupyter notebook?
body: <p>I'm drawing scatter plot in jupyter notebook which contains 2 cells</p>
  <pre><code>from matplotlib import pyplot as plt
  import numpy as np
  
  # Plot single point
  # 1st, create a figure
  fig = plt.figure()
  # then create an 'ax' in this figure
  ax = fig.add_subplot(111)
  # plot red point at x=7, y=42
  ax.scatter(x = [7], y = [42])
  </code></pre>
  <p>and</p>
  <pre><code># Plot multiple points
  # create a center
  center = (7, 42)
  # sample scaled normal distribution
  datapoints = 10 * np.random.randn(50, 50)
  # re-center data
  datapoints[0, :] += center[0]
  datapoints[1, :] += center[1]
  # plot red point for every data-point
  ax.scatter(x = datapoints[0, :], y = datapoints[1, :], color = &quot;red&quot;)
  plt.show()
  </code></pre>
  <p>The first cell returns</p>
  <p><a href="https://i.stack.imgur.com/2BDwo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2BDwo.png" alt="enter image description here" /></a></p>
  <p>whereas the second one returns nothing. Could you please elaborate on this problem?</p>
  <p><strong>Update:</strong> I tried to put</p>
  <pre><code>ax
  fig
  </code></pre>
  <p>in the second cell. In particular,</p>
  <pre><code># Plot multiple points
  # create a center
  center = (7, 42)
  # sample scaled normal distribution
  datapoints = 10 * np.random.randn(50, 50)
  # re-center data
  datapoints[0, :] += center[0]
  datapoints[1, :] += center[1]
  # plot red point for every data-point
  ax
  fig
  ax.scatter(x = datapoints[0, :], y = datapoints[1, :], color = &quot;red&quot;)
  plt.show()
  </code></pre>
  <p>But running second cell still returns nothing.</p>