r - 是否可以像 ggplot 一样使图形绘图可移植?

标签 r ggplot2

是否有可能像 ggplot 图一样使基本图形库图可移植?也就是说,您可以将绘图传递给各种函数并调用 print(plot) 而不会遇到错误。

最佳答案

函数对 recordPlot()replayPlot() 做的事情与此类似,但完全不像这样。一个区别是,与 ggplot2lattice 图形不同,图形在记录之前必须先绘制到图形设备上。

# Plot and then record a figure
plot(rnorm(99))
recPlot <- recordPlot()
dev.off()

# Plot recorded figure to default graphics device
replayPlot(recPlot)

# Plot recorded figure to the pdf graphics device
pdf("eg.pdf")
replayPlot(recPlot)
dev.off()

# Look at the data structure that stores the plot
str(rPlot)

关于r - 是否可以像 ggplot 一样使图形绘图可移植?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8482960/

相关文章:

r - ggplot geom_histogram 颜色按因素无法正常工作

r - geom_vline 的行为是否与其他 ggplot geom 的行为不一致?

r - 获取指定边界坐标的 map

r - 零膨胀泊松模型无法拟合

read.fwf 反转所有数字的符号

r - ggplot : lineplot of means of two groups

r - 2因素直方图分析

r - 如何使广义函数更新向量的值?

r - 在 R 中对大型、非常稀疏的二元矩阵进行聚类

r - 如何使用子集函数和变量删除数据框列?