How do I create multiple italicized text labels in a graph using ggplot2?

I have built a grouped line graph using ggplot2

.

I used the annotation function in ggplot2 to input p-values ​​for the t-tests of each day as labels.

I need to turn each "p" into italics, keeping the normal text for equals and numbers. The code for the labels as they are displayed on the chart is as follows

annotate("text", x = 1:7, y = c(15,30,35.7,29.6,38.2,37.1,43),
label = c("p = .36","p = .05","p = .20","p = .13","p = .47","p = .12","p = .97"),
           size = 4.2)

      

I tried to create an object using bquote

which does a great job with italics. But this requires the use of a function text

that is not recognized in the package ggplot2

.

The problem is that I can't find a way to create a composite label vector with partial italics and partial normal text.

+3


source to share


1 answer


qplot(0,0,geom="blank") + annotate("text", x=0, y=0 , label="italic(p)==0.2", parse=TRUE)

      



+6


source







All Articles