我希望将以下内容替代为绿线条目的图例(cptsdtbehavioralm):
$P_{M1}(\tilde{z}>z) - P_{M0}(\tilde{z}>z)$
并将以下内容替代为蓝线条目的图例(fullbehavioralmodel):
$P_{M2}(\tilde{z}>z) - P_{M0}(\tilde{z}>z)$
这是我生成该图的代码(省略了一万个观察数据集和生成函数Fm0、Fm1和Fm2的转换):
bmp("bias_plot_v4.bmp", width=540, pointsize=10)
ggplot(data.frame(x=c(0,80)),aes(x) ) +
stat_function(fun=function(x)((1-Fm1(x)) - (1- Fm0(x))), geom="line",
aes(colour="cptsdtbehavioralm"), n=1000) +
stat_function(fun=function(x)((1-Fm2(x)) - (1- Fm0(x))), geom="line",
aes(colour="fullbehavioralmodel"), n=1000) +
theme_bw() +
ylab("Probability") +
xlab(expression(paste("Security breaches per 3-week spear-phishing campaign ",
italic( (z) )))) +
theme(aspect.ratio=.618) +
theme(legend.position=c(0.845,0.8)) +
theme(legend.key = element_blank()) +
scale_color_manual(values = c("cptsdtbehavioralm"="green2",
"fullbehavioralmodel" = "blue"), name="Bias")
dev.off()
每当我尝试用一个数学表达式替换“cptsdtbehavioralm”和“fullbehavioralmodel”,例如保持简单,expression(P[{M1}])
时,我会遇到以下类型的错误:
Error: unexpected '=' in:
" theme(legend.key = element_blank()) +
scale_color_manual(values = c(expression(P[{M1}]))="
我已经束手无策了——任何见解或建议都将不胜感激。