我的目标是在我的图例中有多行看起来像这种格式的Nsubscript(M),Nsubscript(F)。下标将用于使我的传说速记。将会有变量需要评估以获取数值。如何用下标和变量制作多行图例?为R图的多个图例使用下标和变量
我需要得到多个bquotes才能工作。下面的格式是我想要的图例部分。
#this works
N_male<-4#random variable
N_female<-6#random variable
plot(x=2,y=3)#random plot
legend("topright",legend=bquote('N'['F']*' = '*.(N_female)),
text.col="black",box.col=0, bty="n", cex = .75, lty= c(2)) #this legend has
#correct syntax
但是我需要让多个bquotes在同一个图例中工作。我怎么做?
#this does not work
N_male<-4#random variable
N_female<-6#random variable
plot(x=2,y=3)
legend("topright",legend=c(bquote('N'['M']*' = '*.(N_male)),
bquote('N'['M']*' = '*.(N_female))),
text.col="black",box.col=0, bty="n", cex = .75, lty= c(1,2)) #this legend does not evaluate the bquote part
不要编辑问题标题,包括对问题情况的意见。如果答案解决了您的问题,请单击旁边的复选标记,问题将自动标记为“已解决”。 – joran