View source: R/add_colourscale.R
add_colourscale | R Documentation |
This function adjusts the colour scales of the animation frames created with frames_spatial
and custom map imagery.
add_colourscale(
frames,
type,
colours,
labels = waiver(),
na.colour = "grey50",
na.show = TRUE,
legend_title = NULL,
verbose = TRUE
)
frames |
an object of class |
type |
character, either |
colours |
character, a vector of colours. If |
labels |
character, a vector of labels with the same length as |
na.colour |
character, colour to use for missing values. |
na.show |
logical, whether to display NA values in discrete scaling. Ignored, if |
legend_title |
character, a legend title. |
verbose |
logical, if |
A frames object of class moveVis
.
Jakob Schwalb-Willmann
frames_spatial
frames_graph
animate_frames
library(moveVis)
library(move)
data("move_data", "basemap_data")
# align movement
m <- align_move(move_data, res = 4, unit = "mins")
# create spatial frames with frames_spatial:
r_list <- basemap_data[[1]]
r_times <- basemap_data[[2]]
## Not run:
frames <- frames_spatial(m, r_list = r_list, r_times = r_times, r_type = "gradient",
fade_raster = TRUE)
frames[[100]] # take a look at one of the frames
# default blue is boring, let's change the colour scale of all frames
frames <- add_colourscale(frames, type = "gradient", colours = c("orange", "white", "darkgreen"),
legend_title = "NDVI")
frames[[100]]
# let's make up some classification data with 10 classes
r_list <- lapply(r_list, function(x){
y <- raster::setValues(x, round(raster::getValues(x)*10))
return(y)
})
# turn fade_raster to FALSE, since it makes no sense to temporally interpolate discrete classes
frames <- frames_spatial(m, r_list = r_list, r_times = r_times, r_type = "discrete",
fade_raster = FALSE)
frames[[100]]
# now, let's assign a colour per class value to frames
colFUN <- colorRampPalette(c("orange", "lightgreen", "darkgreen"))
cols <- colFUN(10)
frames <- add_colourscale(frames, type = "discrete", colours = cols, legend_title = "Classes")
frames[[100]]
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.