4

R中的图有句柄吗?例如,如果我要使用这样的东西:

plot(plotData[,1], plotData[,2], type='l', col='red', lty=2, xlab='x', 
    ylab='y', main='sample plot')

以后我能否更改此图中的任何内容,例如颜色、x 轴标签或 x 轴范围等?还是我把这个情节重演了一遍?

谢谢!

4

1 回答 1

4

Base R does not have handles in the sense that you are asking. Although you can modify some aspects of the plot after you've plotted it, much better suited to the needs in question would be to use ggplot

You can save the output to an object and append as needed.
You can also use last_plot()

Have a look at http://www.cookbook-r.com/Graphs/ and http://docs.ggplot2.org/current/

于 2013-11-13T16:44:46.253 回答