Using expression(paste( to insert math notation into a legend

五迷三道 提交于 2019-11-28 10:02:37

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!