I've consulted a number of helpful SO posts to help me place right- and left-facing triangle symbols on my plot. I wanted to indicate the start of data collection, and the end of data collection. The Webdings font has some nice caret symbols that do the trick:
library(ggplot2)
mydata <- data.frame(x = c(1, 2, 5, 6),
y = c(4, 4, 4, 4),
type = c("start", "end", "start", "end"),
symbols = c(4, 3, 4, 3))
ggplot() +
geom_text(data = mydata, aes(x, y, label = symbols),
size = 8, family = "Webdings")
However, I'd like to label the symbols in my legend as "start" and "end". Is there a way to do this easily?
I could try and make the triangles using geom_point
instead of geom_text
, but - then I'm not sure how to tell my plot that the symbols should be interpreted as Webdings, not regular text.
ggplot() +
geom_point(data = mydata, aes(x, y, shape = type), size = 8) +
scale_shape_manual(values = as.character(mydata$symbols))
What I want: