【发布时间】:2013-10-30 17:24:52
【问题描述】:
我希望替换以下内容(是的,我在这里以 TeX 格式编写,只是为了清楚起见)$P_{M1}(\tilde{z}>z) - P_{M0}(\tilde{z}>z)$
对于绿线的图例条目 (cptsdtbehavioralm),以及$P_{M2}(\tilde{z}>z) - P_{M0}(\tilde{z}>z)$
对于蓝线的图例条目(fullbehavioralmodel)。
这是我生成绘图的代码(我省略了 10,000 次观测数据集和生成函数 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}]))="
我已经束手无策了——任何见解或建议都会非常非常欢迎。
【问题讨论】:
-
这个例子是高度un可重现的。创建一个小示例,以及将返回错误的代码。目前看来你打错了方程,(过早关闭括号),但这纯粹是猜测......