rpngjupyter-notebookjupyter-irkernel

r graphs in jupyter - unable to start png() device


I am using R in Jupyter, but unable to plot graphs in the notebook itself.

Here is a reproducible example

set.seed(123)
mat = as.matrix(x = rnorm(100), y = rnorm(100))
plot(mat)

In Jupyter:

Error in png(tf, width, height, "in", pointsize, bg, res, antialias = antialias): unable to start png() device
Traceback:

If I use following, I can save the image in png format in current working directory.

png('test.png')
plot(mat)
dev.off()

Edit:

SessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

I have gone through following but none of them solve my problem.

  1. Displaying ggplot2 graphs from R in Jupyter
  2. unable to plot in jupyter notebook using R kernel
  3. libXrender.so.1 is required to display R plots inline
  4. Can't display png
  5. Rendering of graphs in R kernel Notebooks on GitHub (relevant to Github)

Solution

  • I had exactly the same issue. I closed Anaconda, opened it again and then updated the kernel; Finally, it worked again without any error.

    conda install -c r r-essentials