【问题标题】:In R using a variable in plotmat used in mtext() on histogram在 R 中,在直方图上使用 mtext() 中使用的 plotmat 中的变量
【发布时间】:2013-10-10 09:54:56
【问题描述】:
    m <- mean(outcome[, 11], na.rm = TRUE)

   hist(df[, 11], main = "",xlab="", ylab="", xlim = c(0,as.integer(range(df[,11], na.rm=TRUE))[-1]), axes = FALSE)
   axis(side = 1, at = c(10,15,20))
   axis(side = 2, at = c(0,200,400,600), labels=c(0,200,'',600),pos=c(as.integer(range(df[,23], na.rm=TRUE))[-2],0))
   mtext(expression(paste(plain("My Title("), hat(X)== substitute(m) , plain(")"))), side=3, line= 2, cex = 1, at=14)

如何在mtext中使用m的值?

此链接here 提出了两种适用于 text() 但不适用于 mtext() 的方法。

【问题讨论】:

    标签: r histogram plotmath


    【解决方案1】:

    我认为 line=2 使它从绘图区域的边缘打印出来。尝试使用 bquote 而不是 paste():

     mtext(bquote( plain("My Title(")* hat(X) == .(m) * plain(")")), 
           side=3,  cex = 1, at=14)
    

    当您删除 paste() 策略时,您需要使用波浪号(空格)和星号(无空格)来连接组件。

    【讨论】:

    • 感谢即使使用 line=2 code: mtext(bquote(plain("My Title(")* hat(X) == .(m) * plain(")")), side=3, line= 2, cex = 1, at=14)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-06
    • 2013-10-16
    • 2013-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多