nlesc-sherlock / emma

Ansible playbook to create a cluster with GlusterFS, Docker, Spark and JupyterHub services
Apache License 2.0
3 stars 4 forks source link

Inline plots with Jupyter Notebooks not possible. #50

Closed romulogoncalves closed 7 years ago

romulogoncalves commented 7 years ago

It is not possible to have inline plots: %matplotlib inline Name: Error parsing magics! Message: Magics [mapplotlib] do not exist! StackTrace:

But also not possible to run the following when creating PySpark notebook:

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

matplotlib.use('Agg')
matplotlib.matplotlib_fname()

y = [2,4,6,8,10,12,14,16,18,20]
x = np.arange(10)
fig = plt.figure()
ax = plt.subplot(111)
ax.plot(x, y, label='$y = numbers')
plt.title('Legend inside')
ax.legend()
#plt.show()

fig.savefig('plot.png') 

window = Tk.Tk() File "/usr/lib/python3.5/tkinter/init.py", line 1871, in init self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable

romulogoncalves commented 7 years ago

It is possible if we open a Python notebook instead of a Toree PySpark notebook. With a normal Python notebook we can connect to Spark, push down data processing and then plot the results in Python.