% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/events_phase_plots.R
\name{plot_event_climate_relation}
\alias{plot_event_climate_relation}
\title{Plot event-based climate-response relationships}
\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{
\item{event_data}{Output of \code{dm_event_climate()}.}

\item{climate_var}{Name of the climate-derived column.}

\item{response_var}{Name of the response variable.}

\item{group_var}{Optional grouping variable for color.}

\item{Year}{Optional numeric year or vector of years for filtering.}

\item{DOY}{Optional numeric vector of length 2 for filtering.}

\item{add_smooth}{Logical. If \code{TRUE}, adds linear fit line.}

\item{point_alpha}{Point transparency.}
}
\value{
A \code{ggplot2} object.
}
\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.
}
\examples{
\donttest{
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"
  )
}
}

}
