1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| yrng <- range(economics$unemploy) xrng <- range(economics$date) caption <- paste(strwrap("Unemployment rates in the US have varied a lot over the years", 40), collapse = "\n") ggplot(economics, aes(date, unemploy)) + geom_line() + geom_text( aes(x, y, label = caption), data = data.frame(x = xrng[1], y = yrng[2], caption = caption), hjust = 0, vjust = 1, size = 4 )
ggplot(economics, aes(date, unemploy)) + geom_line() + annotate("text", x = xrng[1], y = yrng[2], label = caption, hjust = 0, vjust = 1, size = 4 )
|