0

I am very new to emacs and I can't figure out why my plots doesn't appear, I have ein and elpy installed, my code runs but I just can't see the plot. I installed the packages in M-x list-packages.

My .emacs looks like this :

;(setq debug-on-error t)

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-archives
   (quote
    (("gnu" . "http://elpa.gnu.org/packages/")
     ("melpa" . "https://melpa.org/packages/"))))
 '(package-selected-packages (quote (org ein elpy flycheck py-autopep8 material-theme))))

(when (memq window-system '(mac ns))
  (exec-path-from-shell-initialize))

(setq inhibit-startup-message t) ;; hide the startup message
(load-theme 'material t) ;; load material theme
(global-linum-mode t) ;; enable line numbers globally


(elpy-enable)
(elpy-use-ipython)
(require 'ein)

;; use flycheck not flymake with elpy
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

;; enable autopep8 formatting on save
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)


(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

A code snippet :

import matplotlib.pyplot as plt
a = [1,2,3]
b = [1,2,3]
plt.plot(a,b)

Result :

In [7]: Out[7]: [<matplotlib.lines.Line2D at 0x110a80c50>]

How can I make the plot show up ?

1 Answer 1

1

It is not an emacs problem as far as I can see.

To let a plot show up in python (using matplotlib) use:

plt.show()

4
  • I'm sorry for using the main answer to write this little thing, but my reputation is still now high enough to comment your question. Somehow I have to increase it. Oct 31, 2016 at 7:34
  • That's kind embarrassing actually, but worked, I think that I was overly accustomed with and IDE that did all the tricks for me. Oct 31, 2016 at 8:45
  • Don't worry, I'm glad it worked. Sometimes the issues are in the simplest things... Thank you for feedback! Oct 31, 2016 at 11:46
  • after I run plt.show(), this ipython buffer will be dead, can you help?
    – Wei Wu
    Dec 27, 2017 at 9:24

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.