2

I use emacs for most python programming, but really miss the inline plot feature combined with printed output in Spyder. See picture.

enter image description here

I've been experimenting with various interpreter settings but none seem to work:

(use-package python
  :config
  ;; (setq python-shell-interpreter "ipython"
       ;; python-shell-interpreter-args "-i --simple-prompt")
  (setq python-shell-interpreter "jupyter"
        python-shell-interpreter-args "console --simple-prompt"))

Is there a way to setup this functionality in Emacs?

2 Answers2

2

You may wanna checkout ein. Also, spacemacs has a ipython-notebook layer setup based on that; perhaps you can use that as a reference for your own config.

TerryTsao
  • 1,176
  • 4
  • 18
1

Yes, use emacs-jupyter.

Try installing with M-x package-install jupyter (it's in Melpa) or follow the instructions on the Github.

Then configure it to put output (such as plots) into the REPL buffer with (setq jupyter-repl-echo-eval-p t). Without this, output from plots will go into a separate pop-up buffer.

Then call a Jupyter shell as M-x jupyter-run-repl (instead of the usual M-x run-python).

You should be able to verify that it is working quickly (inside the shell you opened). A tip, when you are plotting: you want to say (in your python code) fig.set_facecolor('w') to make things more readable.

from matplotlib import pyplot as plt

fig = plt.figure(figsize=(10,10))
fig.set_facecolor('w')

plt.scatter([1,2,3], [4,5,3])
user38527
  • 3
  • 2
ohrkzt
  • 11
  • 2