简体   繁体   English

R图:标题中使用斜体和变量

[英]R plot: Using italics and a variable in a title

Using R 2.14.0 with windows 7, I want to include italics and a changing variable in my title using R plot(). 在Windows 7中使用R 2.14.0,我想使用R plot()在标题中包含斜体和变化的变量。 Here's some code: 这是一些代码:

ps=c(1,2,3)

layout(matrix(1:3,1,3))

#this works but isn't what I want
for(i in 1:3){
    plot(1,1,main=expression(paste(italic(p),'=5')))
}
#this doesn't work
for(i in 1:3){
    plot(1,1,main=expression(paste(italic(p),'=',ps[i])))
}
#this doesn't work either
for(i in 1:3){
    plot(1,1,main=paste(expression(paste(italic(p),'=')),ps[i]))
}

What I want in the title is p[in italics]=the value of ps during that iteration. 我想要的标题是p [斜体] =迭代期间ps的值。 For instance for the first iteration, " p =0.1" 例如,对于第一次迭代,“ p = 0.1”

Any help would be appreciated. 任何帮助,将不胜感激。 Thanks. 谢谢。

Does this help? 这有帮助吗?

ps=c(1,2,3)
layout(matrix(1:3,1,3))
for(i in 1:3){
    plot(1,1,main=substitute(paste(italic(p), " = 0.", x, sep=""), list(x=ps[i])))
}

Also have a look at this this question. 也看看这个这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM