area_plot: area_plot

View source: R/area_plot.R

area_plotR Documentation

area_plot

Description

Aggregates a data.frame and creates a stacked area chart.

Usage

area_plot(
  data,
  x,
  y = "1",
  group = NULL,
  facet_x = NULL,
  facet_y = NULL,
  size = 11,
  reorder = c("group", "facet_x", "facet_y"),
  palette = ez_col,
  labels_y = if (position == "fill") {
     function(x) ez_labels(100 * x, append =
    "%")
 } else {
     ez_labels
 },
  labels_x = NULL,
  use_theme = theme_ez,
  position = c("stack", "fill"),
  facet_scales = "fixed",
  facet_ncol = NULL,
  legend_ncol = NULL,
  env = parent.frame()
)

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.

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

labels_x

label formatting function

use_theme

ggplot theme function

position

Either "stack" (default) or "fill"

facet_scales

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

facet_ncol

Option passed to ncol argument in facet_wrap or facet_grid. Default is NULL.

legend_ncol

Number of columns in legend.

env

environment for evaluating expressions.

Value

A ggplot object.

Examples


library(tsibble)
library(tsibbledata)
area_plot(ansett, x = "as.Date(Week)", y = "Passengers")
area_plot(ansett,
          x = "as.Date(Week)", y = c("Weekly Passengers" = "Passengers"), "Class")
area_plot(ansett, "as.Date(Week)",
          y = c("Weekly Passengers" = "Passengers"),
          group = "substr(Airports, 5, 7)",
          facet_x = "substr(Airports, 1, 3)",
          facet_y = "Class",
          facet_scales = "free_y")


wkostelecki/ezplot documentation built on Feb. 1, 2024, 10:58 p.m.