R 图:在标题中使用斜体和变量 [英] R plot: Using italics and a variable in a title

查看:98
本文介绍了R 图:在标题中使用斜体和变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 7 中使用 R 2.14.0,我想使用 R plot() 在我的标题中包含斜体和一个变化的变量.这是一些代码:

Using R 2.14.0 with windows 7, I want to include italics and a changing variable in my title using 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]))
}

标题中我想要的是 p[in italics]=该迭代期间 ps 的值.例如对于第一次迭代,p=0.1"

What I want in the title is p[in italics]=the value of ps during that iteration. For instance for the first iteration, "p=0.1"

任何帮助将不胜感激.谢谢.

Any help would be appreciated. Thanks.

推荐答案

这有帮助吗?

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])))
}

另请查看this这个问题.

这篇关于R 图:在标题中使用斜体和变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆