【问题标题】:Storing plot objects in R [duplicate]在R中存储绘图对象[重复]
【发布时间】:2015-05-10 03:19:25
【问题描述】:

本页Generating names iteratively in R for storing plots 提到了两种将绘图对象存储在列表或名称字符串中的方法。但两者似乎都不适用于我的系统。

> plist = list()
> plist[[1]] = plot(1:30)
> 
> plist
list()
> 
> plist[[1]]
Error in plist[[1]] : subscript out of bounds

第二种方法:

> assign('pp', plot(1:25))
> 
> pp
NULL

我正在使用:

> R.version
               _                           
platform       i486-pc-linux-gnu           
arch           i486                        
os             linux-gnu                   
system         i486, linux-gnu             
status                                     
major          3                           
minor          2.0                         
year           2015                        
month          04                          
day            16                          
svn rev        68180                       
language       R                           
version.string R version 3.2.0 (2015-04-16)
nickname       Full of Ingredients         

问题出在哪里?

【问题讨论】:

  • 基本图形绘图函数(即plot())不返回对象。这仅适用于晶格(例如xyplot())或ggplot 对象(呃qplot())。该问题的公认答案具有误导性。

标签: r object plot


【解决方案1】:

使用recordPlotreplayPlot

plot(BOD)
plt <- recordPlot()
plot(0)
replayPlot(plt)

【讨论】:

    猜你喜欢
    • 2010-12-21
    • 2012-12-26
    • 1970-01-01
    • 2021-08-26
    • 2016-02-11
    • 2015-06-17
    • 2013-12-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多