View source: R/events_phase_plots.R
| plot_event_climate_relation | R Documentation |
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.
plot_event_climate_relation(
event_data,
climate_var,
response_var,
group_var = NULL,
Year = NULL,
DOY = NULL,
add_smooth = TRUE,
point_alpha = 0.7
)
event_data |
Output of |
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 |
point_alpha |
Point transparency. |
A ggplot2 object.
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"
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.