是否有可能使图形绘图像ggplot一样可移植? [英] Is it possible to make Graphics plot portable like ggplot?

查看:95
本文介绍了是否有可能使图形绘图像ggplot一样可移植?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to make a base Graphics-library plot portable in the same way that ggplot plots are portable? That is, you can pass the plot to various functions and call print(plot) without encountering an error.

推荐答案

函数 recordPlot() replayPlot()类似于 这个。一个区别是,与 ggplot2 lattice 图形不同,该图必须首先绘制到图形设备之前

The pair of functions recordPlot() and replayPlot() do something similar to, but not exactly like this. One difference is that, unlike with ggplot2 and lattice graphics, the figure must be first plotted to a graphics device before it is recorded.

# 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)

这篇关于是否有可能使图形绘图像ggplot一样可移植?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆