是否有可能像 ggplot 图一样使基本图形库图可移植?也就是说,您可以将绘图传递给各种函数并调用 print(plot) 而不会遇到错误。
最佳答案
函数对 recordPlot()
和 replayPlot()
做的事情与此类似,但完全不像这样。一个区别是,与 ggplot2
和 lattice
图形不同,图形在记录之前必须先绘制到图形设备上。
# 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/