% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_dm.detrend.R
\name{plot.dm_detrended}
\alias{plot.dm_detrended}
\title{Plot detrended dendrometer series}
\usage{
\method{plot}{dm_detrended}(
  x,
  y = NULL,
  type = c("compare", "fit", "residual", "detrended", "boxplot"),
  series = NULL,
  seasons = NULL,
  x_axis = c("default", "date", "season_day", "doy"),
  facet_by = c("series", "season", "none"),
  ncol = NULL,
  box_group = c("series", "season"),
  show_observed = TRUE,
  show_fitted = TRUE,
  point_alpha = 0.7,
  line_width = 0.8,
  legend_position = "right",
  ...
)
}
\arguments{
\item{x}{An object of class \code{"dm_detrended"} returned by
[dm.detrend.fit()].}

\item{y}{Unused.}

\item{type}{Plot type. One of:
\describe{
  \item{`"compare"`}{Default three-panel comparison of original daily vs
    fitted, residuals, and detrended standardized series.}
  \item{`"fit"`}{Original daily and fitted original-scale values only.}
  \item{`"residual"`}{Residuals only.}
  \item{`"detrended"`}{Detrended standardized series only.}
  \item{`"boxplot"`}{Distribution of detrended standardized values by series
    or season.}
}}

\item{series}{Optional character vector of dendrometer series to plot.
Default is \code{NULL}, meaning all available series are used.}

\item{seasons}{Optional character vector of vegetation-season labels to plot.
Default is \code{NULL}, meaning all seasons are used.}

\item{x_axis}{Character string controlling the x-axis. One of:
\describe{
  \item{`"default"`}{Uses date for `"compare"` and `"fit"`, and season day
    for `"residual"` and `"detrended"`.}
  \item{`"date"`}{Use actual calendar date.}
  \item{`"season_day"`}{Use vegetation-season day.}
  \item{`"doy"`}{Use calendar day-of-year.}
}}

\item{facet_by}{Character string controlling faceting. One of:
\describe{
  \item{`"series"`}{Facet by dendrometer series.}
  \item{`"season"`}{Facet by vegetation season.}
  \item{`"none"`}{No faceting.}
}}

\item{ncol}{Optional integer giving the number of columns in faceted plots
where [ggplot2::facet_wrap()] is used.}

\item{box_group}{For \code{type = "boxplot"}, grouping variable on the x-axis.
One of \code{"series"} or \code{"season"}.}

\item{show_observed}{Logical. If \code{TRUE}, original daily observations are
shown in plot types where relevant. Default is \code{TRUE}.}

\item{show_fitted}{Logical. If \code{TRUE}, fitted original-scale values are
shown in plot types where relevant. Default is \code{TRUE}.}

\item{point_alpha}{Numeric alpha level used for observed points. Default is
\code{0.7}.}

\item{line_width}{Numeric line width used for fitted, residual, and detrended
lines. Default is \code{0.8}.}

\item{legend_position}{Character string specifying legend position.
Default is \code{"right"}.}

\item{...}{Further arguments passed to or from other methods.}
}
\value{
A \code{ggplot2} object.
}
\description{
S3 plotting method for objects returned by [dm.detrend.fit()].

The default plot compares:
\itemize{
  \item original daily dendrometer series,
  \item fitted curve reconstructed on the original daily scale,
  \item residuals (`observed - fitted_original`),
  \item detrended standardized series.
}
}
\examples{
\donttest{
fit1 <- dm.growth.fit(
  df = gf_nepa17,
  TreeNum = 1:2,
  method = "gompertz",
  year_mode = "yearly",
  verbose = FALSE
)

det1 <- dm.detrend.fit(fit1)

plot(det1)
plot(det1, type = "fit")
plot(det1, type = "residual")
plot(det1, type = "detrended")
plot(det1, type = "boxplot")
plot(det1, type = "compare", facet_by = "series")
plot(det1, type = "compare", facet_by = "season")
}

}
