I wish to substitute the following (yes, I\'ve written it here in TeX format, just to be clear)
$P_{M1}(\\tilde{z}>z) - P_{M0}(\\tilde{z}>z)$
for
Here is a simple example of how to use values
and labels
to get what I think you want.
Note that values
map the values in the data to the colours you wish to use, while labels
are the labels you want displayed (so this is where you would put the expression).
ggplot(data = data.frame(x= c(0,5)),aes(x=x)) +
stat_function(fun=dnorm,aes(colour = 'red')) +
stat_function(fun = dexp, aes(colour = 'blue')) +
scale_colour_manual(values = c('red' = 'red','blue' = 'blue'),name = '',
labels = expression(P[M1](tilde(z)>0),P[M0](tilde(z)>0)))