2012-03-15 28 views
12

¿Cómo incluyo un superíndice en la anotación ggplot? Quiero mostrar Rsuperscript2 = somevalue He intentado utilizar parse = VERDADERO dentro anotar .. Me dio = Rsuperscript2, somevalue lugaranotación ggplot2 con superíndices

lm1 <- lm(dData$RF ~ dData$Exp -1) 
lb1 <- paste("R^2 = ", round(summary(lm1)$r.squared,4)) 
p1 <- ggplot(dData, aes(x=dData$Exp, y=dData$RF)) + 
    scale_x_continuous("Experimental") + 
    scale_y_continuous("Predicted") + 
    geom_point() + geom_smooth(method="lm") + 
    annotate("text", x=max(dData$Exp), y=min(dData$RF)+1, label=lb1, 
      hjust=1, size=3, vjust=1) 

Respuesta

28

es el problema con superíndices o con el signo de igualdad? Cambiar a == en la expresión, con parse=TRUE me funciona. No teniendo su dData, aquí hay un ejemplo ficticio.

lb1 <- paste("R^2 == ", round(runif(1),4)) 
qplot(1:10, 1:10) + 
    annotate("text", x=2, y=8, label=lb1, parse=TRUE) 

enter image description here

Cuestiones relacionadas