问题
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.
- Displaying ggplot2 graphs from R in Jupyter
- unable to plot in jupyter notebook using R kernel
- libXrender.so.1 is required to display R plots inline
- Can't display png
- 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