Adding index to points in ggplot
I have a basic plot, with a small number of points on. I would like to label the points with a numeric index, and then have the full description of the point in the legend. These is commonly seen on maps, as shown in the following example: However, there seems to be no built-in function within ggplot to add an index. Here is a MWE of the basic concept: df <- data.frame(x = 6:10, y = 6:10, id = 1:5) df$label <- paste0("Label", df$id) library(ggplot) # Basic plot ggplot(df, aes(x, y)) + geom_point() + geom_label(aes(label = id), nudge_x = 0.2) What I have tried so far is to map the index label t
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.