I am trying to label a plot with the following label:
我试图用以下标签标记一个情节:
"Some Assay EC50 (uM)" where the "u" is a micro symbol.
“一些分析EC50(uM)”,其中“u”是微观符号。
I currently have:
我目前有:
assay <- "Some Assay"
plot(0,xlab=expression(paste(assay," AC50 (",mu,"M)",sep="")))
But that gives: "assay EC50 (uM)" rather than the desired "Some Assay EC50 (uM)".
但这给出了:“测定EC50(uM)”而不是所需的“某些测定EC50(uM)”。
Suggestions? Thanks.
建议?谢谢。
I also tried:
我也尝试过:
paste(assay,expression(paste(" AC50 (",mu,"M)",sep="")),sep="")
3 个解决方案
#1
36
You want a combination of bquote()
and a bit of plotmath fu:
你想要bquote()和一些plotmath fu的组合:
assay <- "Some Assay"
xlab <- bquote(.(assay) ~ AC50 ~ (mu*M))
plot(0, xlab = xlab)
The ~
is a spacing operator and *
means juxtapose the contents to the left and right of the operator. In bquote()
, anything wrapped in .( )
will be looked up and replaced with the value of the named object; so .(assay)
will be replaced in the expression with Some Assay
.
〜是间距运算符,*表示将内容并置到运算符的左侧和右侧。在bquote()中,将查找包含在。()中的任何内容并替换为命名对象的值;所以。(化验)将被表达式替换为Some Assay。
#2
3
another option using mtext
and bquote
使用mtext和bquote的另一种选择
plot(0,xlab='')
Lines <- list(bquote(paste(assay," AC50 (",mu,"M)",sep="")))
mtext(do.call(expression, Lines),side=1,line=3)
Note that I set the xlab to null in the first plot.
请注意,我在第一个图中将xlab设置为null。
EDIT No need to call expression, since bquote will create an expression with replacement of elements wrapped in .( ) by their value. So a goodanswer is :
编辑无需调用表达式,因为bquote将创建一个表达式,用它们的值替换。()中包含的元素。所以好的方面是:
plot(0,xlab='')
Lines <- bquote(paste(.(assay)," AC50 (",mu,"M)",sep=""))
mtext(Lines,side=1,line=3)
#3
2
You also could try the poor man's approach:
你也可以试试穷人的方法:
assay <- "Some Assay"
plot(0, xlab = paste0(assay, " AC50 (µM)"))
It specifies the mu character directly rather than using expressions (and paste0
is just paste
with sep = ""
).
它直接指定mu字符而不是使用表达式(而paste0只是用sep =“”粘贴)。
#1
36
You want a combination of bquote()
and a bit of plotmath fu:
你想要bquote()和一些plotmath fu的组合:
assay <- "Some Assay"
xlab <- bquote(.(assay) ~ AC50 ~ (mu*M))
plot(0, xlab = xlab)
The ~
is a spacing operator and *
means juxtapose the contents to the left and right of the operator. In bquote()
, anything wrapped in .( )
will be looked up and replaced with the value of the named object; so .(assay)
will be replaced in the expression with Some Assay
.
〜是间距运算符,*表示将内容并置到运算符的左侧和右侧。在bquote()中,将查找包含在。()中的任何内容并替换为命名对象的值;所以。(化验)将被表达式替换为Some Assay。
#2
3
another option using mtext
and bquote
使用mtext和bquote的另一种选择
plot(0,xlab='')
Lines <- list(bquote(paste(assay," AC50 (",mu,"M)",sep="")))
mtext(do.call(expression, Lines),side=1,line=3)
Note that I set the xlab to null in the first plot.
请注意,我在第一个图中将xlab设置为null。
EDIT No need to call expression, since bquote will create an expression with replacement of elements wrapped in .( ) by their value. So a goodanswer is :
编辑无需调用表达式,因为bquote将创建一个表达式,用它们的值替换。()中包含的元素。所以好的方面是:
plot(0,xlab='')
Lines <- bquote(paste(.(assay)," AC50 (",mu,"M)",sep=""))
mtext(Lines,side=1,line=3)
#3
2
You also could try the poor man's approach:
你也可以试试穷人的方法:
assay <- "Some Assay"
plot(0, xlab = paste0(assay, " AC50 (µM)"))
It specifies the mu character directly rather than using expressions (and paste0
is just paste
with sep = ""
).
它直接指定mu字符而不是使用表达式(而paste0只是用sep =“”粘贴)。