【发布时间】:2019-06-29 12:56:55
【问题描述】:
这可能是这个问题 (How to save ggrough chart as .png) 的更通用版本。
我正在使用 RStudio。我通常可以以通常的方式保存我的图(png()、jpeg() 和 ggsave()。
但是,我遇到了绘图在 RStudio 查看器中呈现的情况,但上述这些保存命令不起作用。
这是一个来自remiotic 页面https://timelyportfolio.github.io/remiotic/ 的示例:
library(remiotic)
remiotic(
# lines expected to be an array of arrays
# for now do it the really ugly way
# but should be able to fix this fairly easily
data = list(
list(
group = "A",
coordinates = lapply(0:10, function(x) list(x=x, y=runif(1)))
)
),
frame = "XYFrame",
props = list(
shape = "lines",
xAccessor = "x",
yAccessor = "y",
xExtent = c(0, 10),
yExtent = c(0, 1),
lineStyle = list(stroke = "#629"),
margin = list(
top = 20,
right = 40,
bottom = 50,
left = 50
),
axes = list(
list(orient = "left"),
list(orient = "bottom")
)
),
width = "100%"
)
我尝试将jpeg("file")、png("file") 和pdf("file") 放在此代码之前,将dev.off() 放在之后。前两个不创建文件,第三个创建文件,但我无法打开文件,因为它没有将绘图保存到其中。我有一台 Mac;如果我将x11() 放在前面,它会打开新窗口,但会在 RStudio Viewer 中呈现绘图。
如何使用代码(而不是 RStudio 的导出按钮)保存这样的图?
【问题讨论】:
-
可以在浏览器中打开并保存吗?
-
我如何从 RStudio 中做到这一点?