plot.met {apsimx} | R Documentation |
Plot method for object of class ‘met’
Description
Some plots are similar to APSIM, others are different and more useful in some respects
Usage
## S3 method for class 'met'
plot(
x,
...,
years,
met.var,
plot.type = c("ts", "area", "col", "density", "anomaly"),
cumulative = FALSE,
facet = FALSE,
climatology = FALSE,
summary = FALSE
)
Arguments
x |
object of class ‘met’ |
... |
additional arguments. None used at the moment. |
years |
optional argument to subset years |
met.var |
optional argument to choose a certain variable. By default, temperature (min and max) is displayed |
plot.type |
type of plot, default is ‘ts’ or time-series. The options ‘area’ and ‘col’ are only available when summary = TRUE. Option ‘density’ produces a simple plot. Option ‘anomaly’ ignores argument cumulative is treated as TRUE regardless. |
cumulative |
default is FALSE. Especially useful for ‘rain’. |
facet |
whether to display the years in in different panels (facets). Not implemented yet. |
climatology |
logical (default FALSE). Whether to display the ‘climatology’ which would be the average of the data. Ideally, there are at least 20 years in the ‘met’ object. |
summary |
whether to plot ‘summary’ data. (default FALSE). |
Examples
## Read in and plot a met file
extd.dir <- system.file("extdata", package = "apsimx")
ames <- read_apsim_met("Ames.met", src.dir = extd.dir)
plot(ames, years = 2012:2015)
## Perhaps more informative
plot(ames, years = 2012:2015, cumulative = TRUE)
## for rain
plot(ames, met.var = "rain", years = 2012:2015, cumulative = TRUE)
plot(ames, met.var = "rain", years = 2012:2015, cumulative = TRUE, climatology = TRUE)
plot(ames, met.var = "rain", years = 2012:2015, plot.type = "anomaly")
## It is possible to add ggplot elements
library(ggplot2)
p1 <- plot(ames, met.var = "rain", years = 2012:2015, cumulative = TRUE)
p1 + ggtitle("Cumulative rain for 2012-2015")