frames_graph | R Documentation |
frames_graph
creates a list of ggplot2
graphs displaying movement-environment interaction. Each object represents a single frame. Each frame can be viewed or modified individually. The returned list of frames can be animated using animate_frames
.
frames_graph(
m,
r_list,
r_times,
r_type = "gradient",
fade_raster = FALSE,
crop_raster = TRUE,
return_data = FALSE,
graph_type = "flow",
path_size = 1,
path_colours = NA,
path_legend = TRUE,
path_legend_title = "Names",
val_min = NULL,
val_max = NULL,
val_by = 0.1,
verbose = T
)
m |
|
r_list |
list of |
r_times |
list of |
r_type |
character, either |
fade_raster |
logical, if |
crop_raster |
logical, whether to crop rasters in |
return_data |
logical, if |
graph_type |
character, defines the type of multi-temporal graph that should be drawn as frames. Currently supported graphs are:
|
path_size |
numeric, size of each path. |
path_colours |
character, a vector of colours. Must be of same length as number of individual tracks in |
path_legend |
logical, wether to add a path legend from |
path_legend_title |
character, path legend title. Default is |
val_min |
numeric, minimum value of the value axis. If undefined, the minimum is collected automatically. |
val_max |
numeric, maximum value of the value axis. If undefined, the maximum is collected automatically. |
val_by |
numeric, increment of the value axis sequence. Default is 0.1. If |
verbose |
logical, if |
To later on side-by-side join spatial frames created using frames_spatial
with frames created with frames_graph
for animation,
equal inputs must have been used for both function calls for each of the arguments m
, r_list
, r_times
and fade_raster
.
If argument path_colours
is not defined (set to NA
), path colours can be defined by adding a character column named colour
to m
, containing a colour code or name per row (e.g. "red"
. This way, for example, column colour
for all rows belonging to individual A can be set to "green"
, while column colour
for all rows belonging to individual B can be set to "red"
.
Colours could also be arranged to change through time or by behavioral segments, geographic locations, age, environmental or health parameters etc. If a column name colour
in m
is missing, colours will be selected automatically. Call colours()
to see all available colours in R.
An object of class moveVis
. If return_data
is TRUE
, a data.frame
is returned (see return_data
).
Jakob Schwalb-Willmann
frames_spatial
join_frames
animate_frames
library(moveVis)
library(move)
library(ggplot2)
data("move_data", "basemap_data")
# align movement
m <- align_move(move_data, res = 4, unit = "mins")
r_list <- basemap_data[[1]]
r_times <- basemap_data[[2]]
## Not run:
# use the same inputs to create a non-spatial graph, e.g. a flow graph:
frames.gr <- frames_graph(m, r_list = r_list, r_times = r_times, r_type = "gradient",
fade_raster = TRUE, graph_type = "flow")
# take a look
frames.gr[[100]]
# make a histogram graph:
frames.gr <- frames_graph(m, r_list = r_list, r_times = r_times, r_type = "gradient",
fade_raster = TRUE, graph_type = "hist")
# change the value interval:
frames.gr <- frames_graph(m, r_list = r_list, r_times = r_times, r_type = "gradient",
fade_raster = TRUE, graph_type = "hist", val_by = 0.01)
frames.gr[[100]]
# manipulate the labels, since now they are very dense:
# just replace the current scale
frames.gr <- add_gg(frames.gr, expr(scale_x_continuous(breaks=seq(0,1,0.1),
labels=seq(0,1,0.1), expand = c(0,0))))
frames.gr[[100]]
# the same can be done for discrete data, histogram will then be shown as bin plots
# to make your own graphs, use frames_graph to return data instead of frames
frames.gr <- frames_graph(m, r_list = r_list, r_times = r_times, r_type = "gradient",
fade_raster = TRUE, return_data = TRUE)
# then simply animate the frames using animate_frames
# see all add_ functions on how to customize your frames created with frames_spatial
# or frames_graph
# see ?animate_frames on how to animate frames
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.