plot_event_climate_relation: Plot event-based climate-response relationships

View source: R/events_phase_plots.R

plot_event_climate_relationR Documentation

Plot event-based climate-response relationships

Description

Draws a scatterplot between an event-based climate variable and a response variable and annotates the fitted linear relationship with R², slope, and p-value.

Usage

plot_event_climate_relation(
  event_data,
  climate_var,
  response_var,
  group_var = NULL,
  Year = NULL,
  DOY = NULL,
  add_smooth = TRUE,
  point_alpha = 0.7
)

Arguments

event_data

Output of dm_event_climate().

climate_var

Name of the climate-derived column.

response_var

Name of the response variable.

group_var

Optional grouping variable for color.

Year

Optional numeric year or vector of years for filtering.

DOY

Optional numeric vector of length 2 for filtering.

add_smooth

Logical. If TRUE, adds linear fit line.

point_alpha

Point transparency.

Value

A ggplot2 object.

Examples


data(gf_nepa17)
data(ktm_clim_hourly)

zg <- phase.zg(df = gf_nepa17[1:800, ], TreeNum = 1)
evt_maxtwd <- dm_event_climate(
  zg,
  ktm_clim_hourly,
  event = "max_twd",
  windows = c(0, 3, 6, 12, 24),
  mean_vars = c("temp", "VPD", "RH"),
  max_vars  = c("VPD"),
  sum_vars  = c("prec")
)

if (all(c("VPD_mean_prev_6h", "max.twd") %in% names(evt_maxtwd)) &&
    any(is.finite(evt_maxtwd$VPD_mean_prev_6h)) &&
    any(is.finite(evt_maxtwd$max.twd))) {
  plot_event_climate_relation(
    evt_maxtwd,
    climate_var = "VPD_mean_prev_6h",
    response_var = "max.twd",
    group_var = "Phase"
  )
}



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