【问题标题】:r graphs in jupyter - unable to start png() devicejupyter中的r图-无法启动png()设备
【发布时间】:2018-11-29 09:21:26
【问题描述】:

我在 Jupyter 中使用 R,但无法在笔记本本身中绘制图表。

这是一个可重现的例子

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

在 Jupyter 中:

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

如果我使用以下,我可以将图像以 png 格式保存在当前工作目录中。

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

编辑:

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

我已经完成了以下操作,但没有一个能解决我的问题。

  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(与 Github 相关)

【问题讨论】:

  • 因为我无法让它工作,我转向了 R markdown,它更容易与 R studio 一起工作,并提供了更多的灵活性。我有点庆幸我没有及时得到任何答复。我的首选仍然是 Python 和 Jupyter,但如果我必须在 R 中编写代码并呈现,我更喜欢 R markdown。

标签: r png jupyter-notebook jupyter-irkernel


【解决方案1】:

我遇到了完全相同的问题。我关闭了 Anaconda,再次打开它,然后更新了内核;最后,它再次运行,没有任何错误。

conda install -c r r-essentials

【讨论】:

  • 我已经更换了我的笔记本电脑,所以对我来说没有办法知道这是否是正确的答案。今天我安装了 miniconda 和 IRkernel,我的代码似乎可以工作。所以我会接受这个答案。
【解决方案2】:

重新启动内核对我来说效果很好。

【讨论】:

  • 只需加上我的两分钱:实际上对我有用。我的猜测是我之前使用过 png() 和 dev.off() 函数,它可能与一些配置混淆
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-19
  • 2018-09-24
  • 1970-01-01
  • 2013-09-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多