a customizable plotting function that takes in several arguments to plot a temporal trend of a variable over time using ggplo2 package. The function allows the user to customize the x and y variables, the display of error bars, the grouping of the data, the colour and size of the lines, and many other graphical features. The function returns a plot object that can be further customized or saved. This function is currently [Experimental]

plot_temporal_trend(
  data_source,
  x_var = "age",
  x_var_name = "Time (ka BP)",
  y_var = "var",
  y_var_name = "Estimate",
  sel_type = c("single", "group"),
  group_var = NULL,
  display_error = FALSE,
  y_limits = NULL,
  sel_y_trans = "identity",
  sel_x_trans = "reverse",
  x_ticks = seq(0, 12000, 4000),
  y_ticks = seq(0, 1, 0.5),
  n_y_ticks = 3,
  show_rmse = TRUE,
  show_bin_summary = TRUE,
  summary_bin_size = 1000,
  deafult_color_line = "black",
  default_color_rmse_highlight = "red",
  default_color_summary_line = "blue",
  default_color_summary_fill = "lightblue",
  group_color_pallete = NULL,
  line_size = 1,
  line_alpha = 1,
  error_alpha = 0.2,
  summary_line_size = 0.5,
  summary_alpha = 0.5,
  default_text_size = 16
)

Arguments

data_source

data.frame to be plotted.

x_var

Character. The name of the column in data_source containing the x-variable (default: "age")

x_var_name

Character. The name of the x-axis variable (default: "Time (ka BP)")

y_var

Character. The name of the column in data_source containing the y-variable

y_var_name

Character. The name of the y-axis variable

sel_type

Character. The type of time series.

  • "single" - only one series

  • "group" - several series

The function will plot a single line with error bars (if display_error is TRUE). If "group", the function will plot multiple lines with different colours based on the `group_var``

group_var

Character. Name of the variable defining the groups in sel_type.

display_error

Logical. Should an error bar be displayed?

y_limits

The limits of the y-axis in the form of a vector of length 2 (default: NULL). If NULL, the function will calculate the limits automatically.

sel_y_trans

Character. Name of a transformation used in scale_y_continuous (default: "identity")

sel_x_trans

Character. Name of a transformation used in scale_x_continuous (default: "reverse")

x_ticks

Numeric vector with x-ticks.

y_ticks

Numeric vector with y-ticks or "auto" to set them automatically

n_y_ticks

If y_ticks = "auto", then set number of automatic ticks

show_rmse

Locigal. Should root mean square error (RMSE) visualisation be plotted. Only works for group_var = "group"

show_bin_summary

Locigal. Should an age bin summary be plotted? Only works for group_var = "group".

summary_bin_size

Size of time bins to use. Only works for show_bin_summary = TRUE.

deafult_color_line

Character with HEX code.

default_color_rmse_highlight

Character with HEX code.

default_color_summary_line

Character with HEX code.

default_color_summary_fill

Character with HEX code.

group_color_pallete

Optional. Name vector with colours for levels of group_var

line_size

Numeric.

line_alpha

Numeric.

error_alpha

Numeric.

summary_line_size

Numeric.

summary_alpha

Numeric.

default_text_size

Numeric.