Graphics Reference
In-Depth Information
For more on controlling the appearance of the text, see Changing the Appearance of Text .
Using Mathematical Expressions in Annotations
Problem
You want to add a text annotation with mathematical notation.
Solution
Use annotate(geom="text") and set parse=TRUE ( Figure 7-5 ):
# A normal curve
p <- ggplot(data.frame(x = c( -3 , 3 )), aes(x = x)) + stat_function(fun = dnorm)
p + annotate( "text" , x = 2 , y = 0.3 , parse = TRUE
TRUE ,
label = "frac(1, sqrt(2 * pi)) * e ^ {-x^2 / 2}" )
Search WWH ::




Custom Search