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.
I can't, for the life of me, figure out why this simple code will not run without error. In reality I have 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 %sql
magic and manipulating it before I get ready to plot it.
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.
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5, 6, 7, 8]
y = [20, 21, 20.5, 20.81, 21.0, 21.48, 22.0, 21.89]
%matplotlib inline
xyplt = plt.plot(x, y, linestyle='dashed', marker='o', color='red')
NameError Traceback (most recent call last)
<ipython-input-34-747daa8afe0d> in <module>()
1 get_ipython().magic(u'pylab inline')
----> 2 xyplt = plt.plot(x, y, linestyle='dashed', marker='o', color='red')
NameError: name 'x' is not defined