View source: R/plot_ZG_output.R
| plot.ZG_output | R Documentation |
Unified S3 plotting method for objects returned by phase.zg().
It supports time-series views of GRO and TWD, phase ribbons and transitions,
TWD-only plots, ABr summaries, phase-balance views, and boxplots of
phase-level statistics. For boxplots, phase summaries are first assembled to
the requested daily or monthly time scale, and rows with missing x-axis
grouping labels are removed before plotting.
The plotting method operates on the two tables returned by
phase.zg():
ZG_phase: point-level time series with TIME,
dm, Phases, TWD, and GRO;
ZG_cycle: phase-level summaries including
max.twd, AUC.load, AUC.total, and
ABr.value.
## S3 method for class 'ZG_output'
plot(
x,
y = NULL,
DOY = NULL,
Year = NULL,
view = NULL,
type = c("gro_twd", "phase_ribbon", "transition", "twd", "abr", "phase_summary",
"balance", "boxplot"),
temporal = c("raw", "daily", "monthly"),
x_axis = c("time", "doy"),
stat = c("Duration_h", "Magnitude", "rate", "max.twd", "Avg.twd", "STD.twd",
"AUC.load", "AUC.total", "ABr.value"),
phase = c("auto", "TWD", "GRO", "all"),
box_group = c("period", "month_of_year", "doy"),
twd_fun = c("mean", "max"),
gro_fun = c("max", "mean"),
transition_linetype = "dashed",
transition_alpha = 0.55,
cols = c(TWD = "red", GRO = "blue"),
singleton_as_points = TRUE,
balance_mode = c("time_of_day", "duration"),
balance_gap = c("carry_forward", "observed_only"),
...
)
x |
Object of class |
y |
Unused. |
DOY |
Optional numeric vector of length 2 giving start and end day-of-year for truncating the plotting window. |
Year |
Optional numeric year used together with |
view |
Optional backward-compatible argument. Use |
type |
Plot type. One of |
temporal |
Temporal scale. One of |
x_axis |
X-axis style for time-based plots. One of |
stat |
For |
phase |
For |
box_group |
For |
twd_fun |
Aggregation function for point-level TWD when
|
gro_fun |
Aggregation function for point-level GRO when
|
transition_linetype |
Line type used for transition markers. |
transition_alpha |
Transparency of transition markers. |
cols |
Vector of two colours for TWD and GRO. It may be named
( |
singleton_as_points |
Logical. If |
balance_mode |
For |
balance_gap |
For |
... |
Unused. |
ABr formula shown by this plot method.
When type = "abr" or when stat = "ABr.value" is used in
boxplots, the displayed values come directly from phase.zg():
ABr = \max(TWD) \times \left(\frac{AUC_{load}}{\max(TWD)}\right)^{\beta}
where
AUC_{load} = \int_{t_{start}}^{t_{max}} TWD(t)\,dt
and
AUC_{total} = \int_{t_{start}}^{t_{end}} TWD(t)\,dt.
This function does not recompute ABr or AUC values; it only visualizes
the values already stored in the ZG_output object.
Aggregation behavior.
For temporal = "daily" or "monthly", point-level series
are aggregated before plotting. TWD and GRO can be summarized using
"mean" or "max", depending on twd_fun and
gro_fun.
For phase-level summaries in ZG_cycle, the plot method aggregates
statistics by daily or monthly period. In those aggregated summaries:
Duration_h, Magnitude, AUC.load,
AUC.total, and ABr.value are summed;
max.twd is taken as the maximum;
Avg.twd and STD.twd are averaged;
rate is recalculated from aggregated magnitude and duration.
Phase balance.
For type = "balance", two balance styles are available through
balance_mode. With balance_mode = "time_of_day", the plot
draws TWD and GRO intervals on a 0–24 hour y-axis, preserving the order in
which phases occurred within each day, similar to the balance option in
plot.SC_output(). With balance_mode = "duration", the plot
draws stacked bars showing the total number of hours spent in each phase.
Missing or irregular intervals can be handled with balance_gap.
Boxplot statistics.
The following phase-level variables can be visualized in
type = "boxplot". For box_group = "period", boxplots are
drawn on a continuous date axis spanning the selected multi-annual data
window, so empty days or months remain visible as gaps rather than being
removed from the x-axis:
"Duration_h"
"Magnitude"
"rate"
"max.twd"
"Avg.twd"
"STD.twd"
"AUC.load"
"AUC.total"
"ABr.value"
Phase handling.
For phase = "auto", TWD-specific statistics
(max.twd, Avg.twd, STD.twd, AUC.load,
AUC.total, ABr.value) automatically select TWD phases,
whereas GRO-specific variables (Magnitude, rate) select GRO
phases.
A ggplot2 object, returned invisibly.
# data(gf_nepa17)
# zg <- phase.zg(df = gf_nepa17[1:500, ], TreeNum = 1, beta = 0.1)
# Raw GRO and TWD time series
# plot(zg)
# Daily aggregated series
# plot(zg, temporal = "daily")
# Monthly TWD plot
# plot(zg, temporal = "monthly", type = "twd")
# ABr bar plot
# plot(zg, temporal = "monthly", type = "abr")
# Daily phase timing, similar to plot.SC_output balance
# plot(zg, type = "balance", temporal = "daily",
# balance_mode = "time_of_day")
# Stacked phase-duration balance
# plot(zg, type = "balance", temporal = "daily",
# balance_mode = "duration")
# Transition plot in day-of-year coordinates
# plot(zg, type = "transition", x_axis = "doy",
# DOY = c(50, 100), Year = 2017)
# Boxplots of peak TWD
# plot(zg, type = "boxplot", stat = "max.twd",
# temporal = "daily", box_group = "doy")
# Boxplots of AUC.load
# plot(zg, type = "boxplot", stat = "AUC.load",
# temporal = "monthly", box_group = "month_of_year")
# Boxplots of ABr.value
# plot(zg, type = "boxplot", stat = "ABr.value",
# temporal = "monthly", box_group = "month_of_year")
# plot(zg, view = "boxplot", stat = "ABr.value", temporal = "monthly")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.