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 Answers 2

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.

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])
1
  • Wow thanks, this is amazing Nov 27, 2020 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.