line_plot: line_plot

View source: R/line_plot.R

line_plotR Documentation

line_plot

Description

Creates line plots.

Usage

line_plot(
  data,
  x,
  y = "1",
  group = NULL,
  facet_x = NULL,
  facet_y = NULL,
  yoy = FALSE,
  size_line = 1,
  points = FALSE,
  size = 11,
  reorder = c("group", "facet_x", "facet_y"),
  palette = ez_col,
  labels_y = ez_labels,
  limits_y = c(NA, NA),
  use_theme = theme_ez,
  facet_scales = "fixed",
  na.rm = FALSE,
  legend_ncol = NULL
)

Arguments

data

A data.frame.

x

A named character value. Evaluates to a column.

y

A named character value. Evaluates to a column.

group

A character value. Evaluates to a column.

facet_x

A character value. Evaluates to a column.

facet_y

A character. Evaluates to a column.

yoy

Logical used to indicate whether a YOY grouping should be created. Default is FALSE.

size_line

width of line for geom_line(). Default is 1.

points

logical. Option to include points

size

theme size for use_theme(). Default is 14.

reorder

A character vector specifying the group variables to reorder. Default is c("group", "facet_x", "facet_y").

palette

Colour function.

labels_y

label formatting function

limits_y

vector of c(min, max) y-axis limits

use_theme

ggplot theme function

facet_scales

Option passed to scales argument in facet_wrap or facet_grid. Default is "fixed".

na.rm

logical. Option to exclude NAs

legend_ncol

Number of columns in legend.

Value

A ggplot object.

Examples

suppressPackageStartupMessages(library(tsibble))
library(tsibbledata)
line_plot(ansett, x = "Week", y = "Passengers")
line_plot(ansett, x = "Week", y = "Passengers", "Class")
line_plot(pelt, "Year", "Hare", limits_y = c(0, NA))
line_plot(pelt, "Year", c("Hare", "Lynx"), points = TRUE)
line_plot(pelt, "Year", c("Hare", "Lynx"), points = 0.5)
line_plot(pelt, "Year", c("Hare", "Lynx"), points = TRUE, limits_y = c(0, NA))
line_plot(pelt, "Year", "Hare", use_theme = ggplot2::theme_bw)
line_plot(pelt, "Year", c("Hare Population" = "Hare"))
line_plot(pelt[pelt$Year > 1930,], "factor(Year)", c("Hare Population" = "Hare"), points = TRUE)
line_plot(pelt[pelt$Year > 1930,], "factor(Year)", c("Hare", "Lynx"), points = TRUE)

ezplot documentation built on Nov. 26, 2023, 5:07 p.m.