gregsexton/ob-ipython

Inline images not appearing

Opened this issue · 0 comments

I am trying to display inline graphics in ob-ipython. I can display them successfully in the browser in a jupyter notebook. I can also display R graphics inline in org-babel.

With :ipyfile header, no graphic appears. With :file header, an empty image box appears in the results.
I get the same result when exporting to HTML: no output from ipython, yes output from R.

#+BEGIN_SRC ipython :session
import sys
print(sys.executable)
%connect_info
#+END_SRC

#+RESULTS:
#+begin_example
/home/user/tmp/venv/bin/python3
{
  "shell_port": 35141,
  "iopub_port": 47853,
  "stdin_port": 51527,
  "control_port": 59441,
  "hb_port": 37455,
  "ip": "127.0.0.1",
  "key": "...",
  "transport": "tcp",
  "signature_scheme": "hmac-sha256",
  "kernel_name": "python3"
}


#+BEGIN_SRC ipython :session :ipyfile /tmp/image.png :exports both :results raw drawer
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

t = np.linspace(0, 20 * np.pi, 350)
x = np.exp(-0.1 * t) * np.sin(t)
y = np.exp(-0.1 * t) * np.cos(t)

plt.plot(x, y)
plt.axis('equal')

plt.figure().show
plt.plot(y, x)

plt.axis('equal')

# print('Length of t = {}'.format(len(t)))
# print('x .dot. y = {}'.format(x @ y))

#+END_SRC

#+RESULTS:
:results:
:end:

#+BEGIN_SRC R :exports both :results raw drawer graphics :file out.png
library(ggplot2)
n = 1000
qplot(runif(n), rnorm(n))

#+END_SRC

#+RESULTS:
:results:
[[file:out.png]]
:end:

Versions:

Ubuntu 17.10
GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.21) of 2017-09-22, modified by Debian
Org mode version 9.1.9 release_9.1.9-553-gcad9ac 
ob-ipython 20180224.0953-g714745