Hello,
The following uses ggplot2.
First, make up a dataset, since you have not posted one.
lat0 <- 38.736946
lon0 <- -9.142685
n <- 10
set.seed(1)
Date <- seq(Sys.Date() - n + 1, Sys.Date(), by = "days")
Lat <- lat0 + cumsum(c(0, runif(n - 1)))
Lon <- lon0 + cumsum(c(0, runif(n - 1)))
Placename <- rep(c("A", "B"), n/2)
path <- data.frame(Date, Placename, Lat, Lon)
path <- path[order(path$Date), ]
Now, two graphs, one with just one line of all the lon/lat and the other
with a line for each Placename.
library(ggplot2)
ggplot(path, aes(x = Lon, y = Lat)) +
geom_point() +
geom_line()
ggplot(path, aes(x = Lon, y = Lat, colour = Placename)) +
geom_point(aes(fill = Placename)) +
geom_line()
Hope this helps,
Rui Barradas
Às 21:27 de 31/10/2018, Ferri Leberl escreveu:
Dear All,
I have a dataframe with four cols: Date, Placename, geogr. latitude, geogr.
longitude.
How can I plot the path as a line, ordered by the date, with the longitude as
the x-axis and the latitude as the y-axis?
Thank you in advance!
Yours, Ferri
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.