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

折月煮酒 提交于 2019-12-22 08:10:03

问题


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)

回答1:


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



回答2:


Restarting the kernel worked fine with me.



来源:https://stackoverflow.com/questions/50944878/r-graphs-in-jupyter-unable-to-start-png-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!