Using [removed]paste( to insert math notation into a legend

后端 未结 1 1643
眼角桃花
眼角桃花 2020-12-05 20:18

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

相关标签:
1条回答
  • 2020-12-05 21:00

    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)))
    

    enter image description here

    0 讨论(0)
提交回复
热议问题