Created
August 16, 2013 04:07
-
-
Save aaronsaunders/6247227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dat <- data.frame(x = rnorm(10), y = rnorm(10), label = letters[1:10]) | |
#Create a subset of data that you want to label. Here we label points a - e | |
labeled.dat <- dat[dat$label %in% letters[1:5] ,] | |
ggplot(dat, aes(x,y)) + geom_point() + | |
geom_text(data = labeled.dat, aes(x,y, label = label), hjust = 2) | |
#Or add a separate layer for each point you want to label. | |
ggplot(dat, aes(x,y)) + geom_point() + | |
geom_text(data = dat[dat$label == "c" ,], aes(x,y, label = label), hjust = 2) + | |
geom_text(data = dat[dat$label == "g" ,], aes(x,y, label = label), hjust = 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment