Short moveVis example on how to adapt the path legend of frames created with frames_spatial()
library(moveVis) | |
library(move) | |
library(ggplot2) | |
data("move_data") | |
# align movement to unique times and regular resolution | |
m <- align_move(move_data, res = 4, unit = "mins") | |
# some path colours by individual | |
m.list <- split(m) # split m into list by individual | |
m.list <- mapply(x = m.list, y = c("red", "green", "blue"), function(x, y){ | |
x$colour <- y | |
return(x) | |
}) | |
m <- moveStack(m.list) | |
# define legend title when calling frames_spatial() | |
frames <- frames_spatial(m, map_type = "watercolor", path_legend = T, path_legend_title = "A title") | |
frames[[100]] # have a look | |
# change legend title afterwards, allows you to also adjust its appearance: e.g. red and bold | |
frames <- add_gg(frames, expr(list(guides(colour = guide_legend(title = "Changed title")), | |
theme(legend.title = element_text(colour = "red", size=10, face = "bold"))))) | |
frames[[100]] # have a look | |
# change legend items by overwriting legend with manual colours and labels | |
frames <- add_gg(frames, expr(scale_colour_manual(values = c("green", "red", "blue") , labels = c("T342g", "T246a", "T932u")))) | |
frames[[100]] # have a look |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment