使用Rqtl包的R图上希腊字母的问题

时间:2019-11-13 10:03:15

标签: r plot legend

我正试图在图例中绘制带有希腊符号的QTL图:

  

LOD(π,μ)

这是我的代码:

plot(outFW.2p14a,lodcolumn=1:3, col = c("black","blue","green"),
       ylab="LOD scores for 2014",ylim=c(0,5), main="B")
legend("topright", 
legend=c("LOD(π,μ)", "LOD(π)","LOD(μ)"," ",
"LOD threshold (μ)","LOD threshold (π)","LOD threshold (π,μ)"),
 col=c("black","blue","green","white","red","red","red"),
lty=c(1,1,1,1,2,3), cex=1.2)

当我使用此代码时,我得到了正确的图,但是希腊符号π出现的图例是错误的,而是显示了一个'p'...就像这样: Legend example with error,对于μ来说就可以了!

我正在使用Rqtl程序包中的遗传数据和表格,但我认为问题并不出在这里,而更多是出自图函数。你知道为什么μ起作用而不是π起作用吗?

对此我将提供一些帮助,因为我尝试了很多事情,但我做对了。我需要它才能在科学期刊上发表论文,所以它必须正确。

最诚挚的问候,

戴安娜

1 个答案:

答案 0 :(得分:0)

如果使用您的代码,我会正确获得符号。

COLS=c("black","blue","green","white","red","red","red")
LABEL1 = c("LOD(π,μ)", "LOD(π)","LOD(μ)"," ",
"LOD threshold (μ)","LOD threshold (π)","LOD threshold (π,μ)")

plot(NULL,ylab="LOD scores for 2014",ylim=c(0,5), main="B",xlim=c(0,5))
legend("topright", 
legend=LABEL1,
 col=COLS,
lty=c(1,1,1,1,2,3), cex=1.2)

enter image description here

可能与您的键盘有些奇怪,请尝试以下操作,在此您可以通过表达式调用符号:

LABEL2 = c(expression(paste("LOD(",pi,",",mu,")")),
expression(paste("LOD(",pi,")")),
expression(paste("LOD(",mu,")")),
expression(paste("LOD threshold(",pi,",",mu,,")")),
expression(paste("LOD threshold (",pi,")")),
expression(paste("LOD threshold (",mu,")"))
)

plot(NULL,ylab="LOD scores for 2014",ylim=c(0,5), main="B",xlim=c(0,5))
legend("topright", 
legend=LABEL2,
 col=COLS,
lty=c(1,1,1,1,2,3), cex=1.2)

enter image description here