【问题标题】:two textplots in one plot一个情节中有两个文本情节
【发布时间】:2014-07-17 21:11:05
【问题描述】:

我一直在尝试在 R 中使用 textplot 并且不确定我的问题是否可行,我知道 par() 不能用于将两个 textplots 放在一个图中。我一直在使用一个页面和这段代码来尝试解决问题。

我的问题是:是否可以在同一个图中有两个文本图? 例如,在下面的 par(mfrow=c(1,1)) 场景中,图 1 是物种长度的 texplot。假设我想在该图中复制该文本图两次。这可能吗?

基于此站点: http://svitsrv25.epfl.ch/R-doc/library/gplots/html/textplot.html

textplot(version)
data(iris)
par(mfrow=c(1,1))
info <- sapply( split(iris$Sepal.Length, iris$Species),
            function(x) round(c(Mean=mean(x), SD=sd(x), N=gdata::nobs(x)),2) )

textplot( info, valign="top"  )
title("Sepal Length by Species")

我想要做的是在该图中放置第二个文本图,在原图下方。为了争论,在图中复制该文本图两次。

这可能吗?

谢谢!

【问题讨论】:

    标签: text plot


    【解决方案1】:

    也许你在过去四个月里已经想通了,但我想我还是会给出答案。

    所提供的代码大部分都可以满足您的要求,您只需向title() 和/或par() 提供一些额外的输入。即使用title("your title", outer = TRUE) 指定标题要在两个图上方,您可以使用par() 中的选项进一步调整标题的位置,使用par(mfrow = c(2,1), oma = c(0,0,"top",0))。希望这能回答您的问题。

    require('gplots')
    
    data(iris)
    
    info <- sapply(split(iris$Sepal.Length, iris$Species), 
               function(x) round(c(Mean = mean(x), SD = sd(x), N = gdata::nobs(x)),2))
    
    ## Replace top with a numerical value to control the position of the title with respect to the
    ## top of the page.
    par(mfrow = c(2,1), oma = c(0,0, top ,0))
    
    textplot(info, valign = "top")
    textplot(info, valign = "top")
    
    title("Sepal Length by Species", outer = TRUE)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多