title: Matplotlib in Jupyter results in variable "is not defined"
body: <p>I'm having a strange issue using Jupyter to plot some simple data. There is a lot of nuance to my specific use-case, not the least of which is a Jupyter notebook connected to our cloud-based Spark cluster with a PySpark kernel.</p>
  
  <p>I can't, for the life of me, figure out why this simple code will not run without error. In reality I <em>have</em> to have the code set up like this, because instead of "x" and "y" I'm dealing with a data frame sourced from a Hive query - using the <code>%sql</code> magic and manipulating it before I get ready to plot it.</p>
  
  <p>Here's a re-creation of the code within my Jupyter notebook - wherein I'm trying to illustrate the separation of code cells. I've tried every combination of ordering the cells and whatnot, I can't fathom why it tells me the "x" variable is not defined.</p>
  
  <pre><code>import matplotlib.pyplot as plt
  </code></pre>
  
  <hr>
  
  <pre><code>x = [1, 2, 3, 4, 5, 6, 7, 8]
  y = [20, 21, 20.5, 20.81, 21.0, 21.48, 22.0, 21.89]
  </code></pre>
  
  <hr>
  
  <pre><code>%matplotlib inline
  xyplt = plt.plot(x, y, linestyle='dashed', marker='o', color='red')
  </code></pre>
  
  <hr>
  
  <pre><code>NameError                                 Traceback (most recent call last)
  &lt;ipython-input-34-747daa8afe0d&gt; in &lt;module&gt;()
        1 get_ipython().magic(u'pylab inline')
  ----&gt; 2 xyplt = plt.plot(x, y, linestyle='dashed', marker='o', color='red')
  
  NameError: name 'x' is not defined
  </code></pre>