ggrepel is in CRAN

repel-peaks-exampleA new package has been accepted in CRAN. It was developed by Kamil Slowikowski and it defines two new geoms for ggplot2: geom_text_repel and geom_label_repel. These geoms work similarly to geom_text() and geom_label() but they “repel” (move) the text or labels so that they do not overlap and plot a segment joining the label or text to their true location. They work nicely with stat_peaks() and stat_valleys() from package ggspectra.

The pdf ggrepel-peaks-example looks better and really shows what can easily be achieved.

library(ggplot) # ver >= 2.0.0

ggplot(sun.spct) + geom_line() +
stat_peaks(span = 11, ignore_threshold = 0.1, pch = 21) +
stat_peaks(span = 11, ignore_threshold = 0.1, geom = “label_repel”,
color = “white”, size = rel(2.5), segment.color = “darkred”) +

Leave a Reply

Your email address will not be published. Required fields are marked *