Description Usage Arguments Examples
Place letters of the given text along a path (x, y). Used in geom_river_label().
1 2 | place_along(text, x, y, offset, dist = 0.5, vpos = 0.2, win = 1,
centred = T, repeated = T, check_length = T)
|
text |
text to place along the path. |
x |
X coordinates of the path. |
y |
y coordinates of the path. |
offset |
distance from the starting point of the path. |
dist |
distance between letters. |
vpos |
Relative distance from the path (negative value put the label under the path). |
win |
width of the window to smooth the slope. |
centred |
if TRUE (default) the label position centred on the path, otherwise it is adjusted to the window defined by the parameter |
repeated |
if TRUE (default) the text is repeated along the path and each label is seperated by the offset, otherwise it is placed only once. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | y <- sort(floor(runif(50)*300)/20)
x <- sort(floor(runif(50)*200)/20)
win <- 6
pos <- place_along("abcefg", x, y, 4, 1.5, 1.5, win = win, centred = 1)
ggplot(data.frame(x, y), aes(x,y))+ geom_path() + geom_text(data=pos, aes(label = label, angle= angle2 * 180 / pi), size = 14) + geom_point(data = pos, aes(refx, refy)) + coord_fixed() #+ geom_arc(data = pos, aes(refx, refy), radius = win/2, width = 15 * 2 * pi)
# Another example with real river data from the riverdist package
river <- Gulk$lines[[14]]
river <- as.data.frame(river)
colnames(river) <- c("x", "y")
river
win <- 1000
pos <- place_along("Gulk", river$x, river$y, 4000, 1000, 500, win = win, centred = 1)
ggplot(river, aes(x,y))+ geom_path() + geom_text(data=pos, aes(label = letter, angle= angle * 180 / pi), size = 8) + geom_point(data = pos, aes(refx, refy)) + coord_fixed()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.