dm_plot_climate_compare: Compare multiple climate variables attached to dendrometer...

View source: R/plot_climate_phase.R

dm_plot_climate_compareR Documentation

Compare multiple climate variables attached to dendrometer outputs

Description

Plots and compares multiple climate variables attached to climate-augmented dendrometer outputs. It works with objects of class daily_output_clim, ZG_output_clim, and SC_output_clim.

Supported plot types include faceted time-series, grouped boxplots, violin plots, combined violin-boxplots, correlation heatmaps, and regression heatmaps.

Usage

dm_plot_climate_compare(
  x,
  climate_vars = NULL,
  numeric_vars = NULL,
  scale = c("auto", "daily", "cycle", "point"),
  type = c("timeseries", "boxplot", "violin", "both", "cor_heatmap",
    "regression_heatmap"),
  group_var = NULL,
  Year = NULL,
  DOY = NULL,
  box_scales = c("free_y", "fixed"),
  cor_method = c("pearson", "spearman", "kendall"),
  use_pairwise = TRUE,
  regression_stat = c("r.squared", "slope", "p.value"),
  point_alpha = 0.5,
  show_values = FALSE,
  temporal = NULL
)

Arguments

x

A climate-augmented dendrometer object.

climate_vars

Character vector of climate variables to compare. If NULL, all detected climate variables at the selected scale are used.

numeric_vars

Optional character vector of numeric variables used when type = "cor_heatmap" or type = "regression_heatmap". If NULL, all numeric variables in the selected data are used.

scale

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

type

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

group_var

Optional character. Grouping variable. If NULL, Day_status is used for daily outputs when available, and Phases is used for 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.

box_scales

Character. Facet scale behavior for grouped plots. One of "free_y" or "fixed".

cor_method

Character. Correlation method. One of "pearson", "spearman", or "kendall".

use_pairwise

Logical. If TRUE, pairwise complete observations are used in correlations.

regression_stat

Character. Statistic shown in regression heatmaps. One of "r.squared", "slope", or "p.value".

point_alpha

Numeric. Alpha value for points.

show_values

Logical. If TRUE, numeric values are printed inside heatmap tiles.

temporal

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

Details

For type = "regression_heatmap", pairwise simple linear regressions are fitted as y ~ x for every variable combination. The heatmap can display R^2, slope, or p-value.

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_compare(
  zg_clim,
  climate_vars = c("temp_mean_phase", "VPD_mean_phase", "RH_mean_phase"),
  scale = "cycle",
  type = "boxplot"
)

plot(
  zg_clim,
  climate_vars = c("temp_mean_phase", "VPD_mean_phase", "RH_mean_phase"),
  scale = "cycle",
  type = "boxplot"
)



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