plot_series: Line plot, one line per group

View source: R/plot.R

plot_seriesR Documentation

Line plot, one line per group

Description

When x is "month", the axis shows month names.

Usage

plot_series(
  data,
  x,
  y,
  by = NULL,
  facet = NULL,
  smooth = NULL,
  span = 2/3,
  ribbon = NULL,
  title = NULL,
  ylabel = NULL
)

Arguments

data

Long data frame

x

Column for the horizontal axis (for example date or year)

y

Column for the vertical axis

by

Optional column. One line (and colour) per value.

facet

Optional column. One panel per value.

smooth

"lowess" or "linear" adds a trend line. The data line is then light grey when there is no by column.

span

Fraction of the points in each LOWESS window (stats::lowess() f)

ribbon

Optional c(low, high) columns to shade, for example c("temperature_min", "temperature_max")

title

Plot title

ylabel

Vertical axis label. The default is y.

Value

ggplot object

Examples


df <- data.frame(year = 2001:2020, t2m = 25 + 0.03 * (1:20) + rnorm(20, sd = 0.2))
plot_series(df, "year", "t2m", smooth = "linear")


varunayan documentation built on Oct. 30, 2026, 1:07 a.m.