R plot without showing the graphic window

前端 未结 2 1008
鱼传尺愫
鱼传尺愫 2020-12-21 06:03

I need to store a plot object in a variable. I know that I can do:

plot(rnorm(10))
obj = recordPlot()
replayPlot(obj)

But I don\'t want to

2条回答
  •  無奈伤痛
    2020-12-21 06:26

    You can do that easily with ggplot2:

    require(ggplot2)
    data = data.frame(x = 1:100, y = rnorm(100))
    p = ggplot(data) + geom_point(aes(x, y)) + theme_classic()
    print(p) # this show the plot
    

提交回复
热议问题