title: %matplotlib notebook magic command in jupyter works only intermittently
body: <p>I really like the <code>%matplotlib notebook</code> magic command for making plots interactive (zoomable) in Jupyter notebooks. But I've found that command often (maybe always?) fails to work if it's called within the same cell as import commands. For example, here's a screenshot of a Jupyter Notebook showing a plot that is not interactive, despite having called <code>%matplotlib notebook</code> in the first cell:</p>
  <p><a href="https://i.stack.imgur.com/7E5bX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7E5bX.png" alt="enter image description here" /></a></p>
  <p>But if I split that first cell such that the magic command is in its own cell, I get an interactive plot as desired. Screenshot below (note that interactive buttons surrounding the plot in this image):</p>
  <p><a href="https://i.stack.imgur.com/Ml5Z8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ml5Z8.png" alt="enter image description here" /></a></p>
  <p>I've just been trying to train myself put the <code>%matplotlib notebook</code> call in its own cell, as shown in the second example, but I'm curious if there's some known underlying reason why this is occuring?</p>