1

I use below org code to draw a graph, but the graph not show on results block:

#+BEGIN_SRC ipython :results drawer :session py2session
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

fig=plt.figure(facecolor='white')
plt.hist(np.random.randn(500000), bins=100);
#+END_SRC

#+RESULTS:
:RESULTS:
<matplotlib.figure.Figure at 0x112819f90>
:END:

How can I draw the output graph from ipython to results block?

2

Your example works perfectly in my setup.

First make sure ipython-ob is included in the babel-languages: in my case:

(org-babel-do-load-languages
 'org-babel-load-languages
 '((python . t)
   (ipython . t)
   (ledger . t)
   (latex . t)
   (clojure .t)
   (shell .t)
    ))

THEN display images online added to your init file:

(add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append)

The plot as it should be]

  • Thanks, I use minimal config just the same as yours but it still doesn't work! I am using MacOsx and emacs version is 25.2, Not sure if any other config impact on this case! – lucky1928 Sep 5 '18 at 16:42
  • Just to confirm... You aren't trying this in terminal, right? – manandearth Sep 5 '18 at 21:26
  • Right, I run it in GUI, try it with -nw option also, behavior the same. – lucky1928 Sep 6 '18 at 0:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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