plot_line: Function to plot time series of atlantis ncdf output.

Description Usage Arguments Value See Also Examples

View source: R/plot-line.R

Description

Function to plot time series of atlantis ncdf output.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plot_line(
  data,
  x = "time",
  y = "atoutput",
  wrap = "species",
  col = NULL,
  ncol = 7,
  yexpand = FALSE,
  ylim = NULL
)

Arguments

data

Dataframe to be plotted.

x

x-variable. Default is 'time'.

y

y-variable. Default is 'atoutput'.

wrap

Wraping column. Default is 'species'

col

Column to use as colour. Default is NULL.

ncol

Number of columns in multipanel plot. Default is 7.

yexpand

Expands the y axis so it always includes 0. Default is FALSE.

ylim

Numeric vector. lower and upper limits of yaxis, eg c(0,1)

Value

ggplot2 object

See Also

Other plot functions: plot_bar(), plot_boxes(), plot_diet_bec_dev(), plot_diet(), plot_rec(), plot_species()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
plot_line(preprocess$biomass)
plot_line(preprocess$biomass, col = "species")
plot_line(preprocess$biomass_age, col = "agecl")
plot_line(preprocess$biomass_age, wrap = "agecl", col = "species")

# The function can also be used to compare model outoput with observed data.
d <- system.file("extdata", "setas-model-new-becdev", package = "atlantistools")
ex_data <- read.csv(file.path(d, "setas-bench.csv"), stringsAsFactors = FALSE)
names(ex_data)[names(ex_data) == "biomass"] <- "atoutput"

data <- preprocess$biomass
data$model <- "atlantis"
comp <- rbind(ex_data, data, stringsAsFactors = FALSE)

# Show atlantis as first factor!
lev_ord <- c("atlantis", sort(unique(comp$model))[sort(unique(comp$model)) != "atlantis"])
comp$model <- factor(comp$model, levels = lev_ord)

# Create plot
plot_line(comp, col = "model")

## Not run: 
# Use \code{\link{convert_relative_initial}} and \code{\link{plot_add_box}}
# with \code{\link{plot_line}}. Use \code{\link{convert_relative_initial}} to
# generate a relative time series first.
df <- convert_relative_initial(preprocess$structn_age)

# Create the base plot with \code{\link{plot_line}}.
plot <- plot_line(df, col = "agecl")

# Add lower and upper range.
plot_add_box(plot)

# Create spatial timeseries plots in conjuction with \code{\link{custom_grid}}.
plot <- plot_line(preprocess$physics, wrap = NULL)
custom_grid(plot, grid_x = "polygon", grid_y = "variable")

plot <- plot_line(preprocess$flux, wrap = NULL, col = "variable")
custom_grid(plot, grid_x = "polygon", grid_y = "layer")

## End(Not run)

alketh/atlantistools documentation built on Oct. 30, 2021, 5:46 a.m.