I would like to create 3 plots each containing a plot of 2 lines from different data frames, and then label each plot with a specific fraction.
So for example I have the 3 data frames:
df1 <- data.frame(x=c(1,2,3,4),y=c(2,3,4,5), z=c(3,3,6,8))
df2 <- data.frame(x=c(3,4,5,6),y=c(1,3,6,7), z=c(2,4,4,8))
df3 <- data.frame(x=c(1,2,2,3),y=c(2,5,6,9), z=c(2,5,6,7))
And I would like to:
1) Create 3 different plots for each data frame, each with one red and one blue line;
2) Add an annotation over the blue line of each plot using a different fraction for each plot.
For example the plot for data frame 1 is something like this:
p1 <- ggplot(data = df1) + geom_line(aes(x=x,y=y, colour="blue")) + geom_line(aes(x=x,y=z, colour="red")) + scale_colour_manual(name="data", values=c("red", "blue"))
Then to add the labels over the blue line I have tried:
p1 + geom_text(aes(x=df1$x[which.max(df1$y)]+1, y = max(df1$y)+4, label = "{\frac{23 22 22}{44 28 32}}", size=2, parse=TRUE))
But this does not work, and I have searched so many hours and cannot find how to use fractions (and brackets enclosing the fraction) in the annotations. Any help is deeply appreciated!
-fra