Simon Jackson shows how you can use the secondary axis to label line endings in ggplot2:
Now we can use
scale_y_*
, with the argumentsec.axis
to create a second axis on the right, with numbers to be displayed atbreaks
, defined by our vector of line ends:ggplot(d, aes(age, circumference, color = Tree)) + geom_line() + scale_y_continuous(sec.axis = sec_axis(~ ., breaks = d_ends))
This is good. I’d really prefer to show the labels instead of the value; that way it’d be possible to eliminate the legend altogether. H/T R-Bloggers.