View source: R/plot_phenology_trends.R
plot_phenology_trends | R Documentation |
The timing of many development stages of temperate trees may depend on temperatures during two
phases (e.g. bloom dates depend on the temperature during both the chilling and forcing phase of dormancy).
plot_phenology_trends()
illustrates this dependency as a colored surface with contour lines by applying an
interpolating procedure with functions in the fields
package. The plot is implemented
through functions in the ggplot2
package.
plot_phenology_trends(
pheno_data,
weather_data,
split_month = 6,
chilling_phase,
forcing_phase,
Krig_warn = TRUE,
x_axis_name = NULL,
y_axis_name = NULL,
legend_name = NULL,
contour_line_color = "black",
point_color = "black",
point_shape = 19,
legend_colors = NULL,
base_size = 11,
...
)
pheno_data |
is a data frame that contains information on the timing of phenology events by year.
It should consist of two columns called |
weather_data |
is a data frame containing daily minimum and maximum temperature data (in columns
called |
split_month |
is an integer representing the last month of the growing season. This procedure analyzes data by phenology year, which can start and end in any month during the calendar year (currently only at the beginning of a month). This variable indicates the last month (e.g. 5 for May) that should be included in the record for a given phenology year. All subsequent months are assigned to the following phenology year. |
chilling_phase |
is a vector of integers representing the start and end for the chilling period in temperate trees. Numbers must be provided in Julian date (day of the year). |
forcing_phase |
is a vector of integers representing the start and end for the forcing period in temperate trees. Numbers must be provided in Julian date (day of the year). |
Krig_warn |
is a boolean parameter passed to the |
x_axis_name |
is a character string that allows the user modifying the default label used in the x axis. |
y_axis_name |
is a character string that allows the user modifying the default label used in the y axis. |
legend_name |
is a character string that allows the user modifying the default label used in the legend. |
contour_line_color |
is a character string representing the color used to draw the contour lines.
Default is set to black. If |
point_color |
is a character string representing the color used to draw the points for actual
observations. Default is set to black. If |
point_shape |
is a numeric input representing the point shape used to draw the points for actual
observations. Default is set to 19 (filled point). If |
legend_colors |
is a character string representing the color scale used in the surface plot.
Default is set to |
base_size |
is a numeric input representing the relative size of the elements in plot. |
... |
accepts arguments passed to |
The generation of the color surface is based on the Kriging technique, which is typically used for interpolation of spatial data. The use for this particular purpose is a bit experimental.
plot_phenology_trends()
is expected to return an object of class gg
and ggplot
. This
means that the plot can be later modified by using the syntax '+'
from the
ggplot2
package (see examples). The plot returned in the function should look as the following:
# Run a simple plot
# Code is commented out, so that it passes the CRAN incoming checks.
# Please uncomment to run the code.
# plot_phenology_trends(pheno_data = chillR::KA_bloom,
# weather_data = chillR::KA_weather,
# chilling_phase = c(306, 350),
# forcing_phase = c(355, 60))
# Customize the aspects of the plot and save it as 'plot'
# plot <- plot_phenology_trends(pheno_data = chillR::KA_bloom,
# weather_data = chillR::KA_weather,
# chilling_phase = c(306, 350),
# forcing_phase = c(355, 60),
# x_axis_name = "Temperatura en el periodo de frio (Celsius)",
# y_axis_name = "Temperatura en el periodo de forzado (Celsius)",
# legend_name = "Fecha de floracion\n(dia juliano)",
# contour_line_color = "white",
# point_color = "blue4",
# point_shape = 4,
# legend_colors = NULL,
# base_size = 14,
# legend.position = "bottom",
# axis.title = ggplot2::element_text(family = "serif"))
# plot
# Modify the plot object with the syntax from ggplot2.
# Be aware that the following code overrides the modifications
# done by the argument '...' in the main function
# plot + ggplot2::theme_classic(base_size = 14)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.