Skip to content

Instantly share code, notes, and snippets.

@16EAGLE
Last active March 7, 2019 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 16EAGLE/d69e3bed11fb6d08ee724868710ff876 to your computer and use it in GitHub Desktop.
Save 16EAGLE/d69e3bed11fb6d08ee724868710ff876 to your computer and use it in GitHub Desktop.
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