View source: R/monthly_figure.R
monthly_figure | R Documentation |
This function produces a standardized line graph with colored area under the line and a trend line. This figure is used for monthly measurements (e.g., precipitation or temperature) in RMarkdown scrips to produce reports.
monthly_figure(
x_var,
y_var,
year_group,
y_intercept,
my_year,
line_color,
my_title,
my_ylab
)
x_var |
A vector of the x-variable. |
y_var |
A vector of the y-variable. |
year_group |
A vector for the grouping variable. |
y_intercept |
A number for the y-intercept of the reference line. Zero (0) or 100 are normally used. |
my_year |
A 4-digit year. This variable is used to subset the data provided by x_var, y_var, and year_group for plotting, and as a label on the figure. |
line_color |
A character string for the line color.See
|
my_title |
A character string for the title. |
my_ylab |
A character string from the y-axis. |
A ggplot object.
library(climateAnalyzeR)
# Import monthly departures
dat <- import_data("departure", 'hovenweep_utah', 2000, 2021) |>
# Create month data frame to make x axis lables
dplyr::left_join(data.frame('month' = 1:12,
'month_abb' = factor(month.abb,
levels = month.abb)))
# Plot data
monthly_figure(x_var = dat$month_abb, y_var = dat$tmax_depart,
year_group = dat$year, y_intercept = 0, my_year = 2020,
line_color = "red3",
my_title = "TMAX Montly Departure, Hovenweep National Monument",
my_ylab = "Departure (deg F)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.