monthly_figure: Monthly Figure

View source: R/monthly_figure.R

monthly_figureR Documentation

Monthly Figure

Description

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.

Usage

monthly_figure(
  x_var,
  y_var,
  year_group,
  y_intercept,
  my_year,
  line_color,
  my_title,
  my_ylab
)

Arguments

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 colors for a list of color names.

my_title

A character string for the title.

my_ylab

A character string from the y-axis.

Value

A ggplot object.

Examples

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)")


scoyoc/climateAnalyzeR documentation built on April 19, 2023, 9:57 p.m.