% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_climate_phase.R
\name{dm_plot_climate}
\alias{dm_plot_climate}
\title{Plot climate attached to dendrometer outputs}
\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{
\item{x}{A climate-augmented dendrometer object.}

\item{climate_var}{Character. Name of the climate variable to plot.}

\item{metric_var}{Optional character. Biological response variable used when
\code{type = "relation"}. If \code{NULL}, a suitable default is selected
when possible.}

\item{scale}{Character. Data level to use. One of \code{"auto"},
\code{"daily"}, \code{"cycle"}, or \code{"point"}.}

\item{type}{Character. Plot type. One of \code{"timeseries"},
\code{"boxplot"}, \code{"violin"}, \code{"both"}, or \code{"relation"}.}

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

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

\item{DOY}{Optional numeric vector of length 2 giving the day-of-year range.}

\item{point_alpha}{Numeric. Alpha value for points.}

\item{add_smooth}{Logical. If \code{TRUE} and \code{type = "relation"},
a linear trend line is added.}

\item{temporal}{Deprecated argument kept for compatibility with older
examples. It is ignored.}
}
\value{
A \code{ggplot2} object, returned invisibly.
}
\description{
General plotting function for dendrometer outputs with attached climate
information. It works with objects of class \code{daily_output_clim},
\code{ZG_output_clim}, and \code{SC_output_clim}, usually produced by
\code{dm_add_climate()}, \code{dm_join_daily_clim()},
\code{dm_join_phase_clim()}, or \code{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.
}
\examples{
\donttest{
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"
)
}

}
