dm_plot_climate: Plot climate attached to dendrometer outputs

View source: R/plot_climate_phase.R

dm_plot_climateR Documentation

Plot climate attached to dendrometer outputs

Description

General plotting function for dendrometer outputs with attached climate information. It works with objects of class daily_output_clim, ZG_output_clim, and SC_output_clim, usually produced by dm_add_climate(), dm_join_daily_clim(), dm_join_phase_clim(), or dm_join_subdaily_clim().

The function can display one selected climate variable through time, by phase or day status, as boxplots or violin plots, or as a climate-response relationship.

Usage

dm_plot_climate(
  x,
  climate_var,
  metric_var = NULL,
  scale = c("auto", "daily", "cycle", "point"),
  type = c("timeseries", "boxplot", "violin", "both", "relation"),
  group_var = NULL,
  Year = NULL,
  DOY = NULL,
  point_alpha = 0.6,
  add_smooth = FALSE,
  temporal = NULL
)

Arguments

x

A climate-augmented dendrometer object.

climate_var

Character. Name of the climate variable to plot.

metric_var

Optional character. Biological response variable used when type = "relation". If NULL, a suitable default is selected when possible.

scale

Character. Data level to use. One of "auto", "daily", "cycle", or "point".

type

Character. Plot type. One of "timeseries", "boxplot", "violin", "both", or "relation".

group_var

Optional character. Grouping variable. If NULL, Day_status is used for daily outputs when available, and Phases is used for cycle- or point-level phase outputs.

Year

Optional numeric year or vector of years for subsetting.

DOY

Optional numeric vector of length 2 giving the day-of-year range.

point_alpha

Numeric. Alpha value for points.

add_smooth

Logical. If TRUE and type = "relation", a linear trend line is added.

temporal

Deprecated argument kept for compatibility with older examples. It is ignored.

Value

A ggplot2 object, returned invisibly.

Examples


data(gf_nepa17)
data(ktm_clim_hourly)

zg <- phase.zg(df = gf_nepa17[1:800, ], TreeNum = 1)
zg_clim <- dm_add_climate(
  zg,
  ktm_clim_hourly,
  scale = "phase",
  mean_vars = c("temp", "VPD", "RH"),
  max_vars  = c("temp", "VPD"),
  sum_vars  = c("prec")
)

dm_plot_climate(
  zg_clim,
  climate_var = "VPD_mean_phase",
  scale = "cycle",
  type = "boxplot"
)

plot(
  zg_clim,
  climate_var = "VPD_mean_phase",
  scale = "cycle",
  type = "boxplot"
)



dendRoAnalyst documentation built on May 20, 2026, 5:07 p.m.