make_segments {animalEKF} | R Documentation |
Plot path connecting points on ggplot.
Description
Convert x-y coordinates to a data.frame
for geom_path
plotting on ggplot
.
Usage
make_segments(xy, N=nrow(xy))
Arguments
xy |
Matrix or |
N |
Number of rows of |
Author(s)
Samuel Ackerman
Examples
#generate toy dataset
library(ggplot2)
d <- as.data.frame(cbind(X=runif(50), Y=runif(50)))
#create segments with some missing lines so will be some gaps)
dseg <- d
dseg[ sample(20),] <- NA
g <- ggplot(d, aes(x=.data$X, y=.data$Y)) + theme_bw()
g <- g + stat_density2d(aes(fill=after_stat(!!str2lang("density"))), geom="tile", contour=FALSE)
g <- g + scale_fill_gradient(low="white", high="black") + theme(legend.position="bottom")
g <- g + geom_path(data=make_segments(xy=dseg), aes(x=.data$X, y=.data$Y), colour="red", lwd=1.5)
g
[Package animalEKF version 1.2 Index]