Package 'ggstream'

Title: Create Streamplots in 'ggplot2'
Description: Make smoothed stacked area charts in 'ggplot2'. Stream plots are useful to show magnitude trends over time.
Authors: David Sjoberg [aut, cre]
Maintainer: David Sjoberg <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2025-02-13 02:40:59 UTC
Source: https://github.com/davidsjoberg/ggstream

Help Index


Worldwide Blockbusters 2019-1977

Description

The Worldwide Blockbusters 2019-1977 dataset provides information on the top ten highest grossing films worldwide between the years 2019 and 1977.

Usage

blockbusters

Format

A data frame with 430 rows and 4 variables:

year

release year of blockbuster

genre

genre of blockbuster title

box_office

Sum of box office per genre and year, billion real dollars

Source

https://www.kaggle.com/narmelan/top-ten-blockbusters-20191977


geom_stream geom to create stream plots

Description

geom_stream

geom to create stream plots

Usage

geom_stream(
  mapping = NULL,
  data = NULL,
  geom = "polygon",
  position = "identity",
  show.legend = NA,
  inherit.aes = TRUE,
  na.rm = TRUE,
  bw = 0.75,
  extra_span = 0.01,
  n_grid = 1000,
  method = c("new_wiggle"),
  center_fun = NULL,
  type = c("mirror", "ridge", "proportional"),
  true_range = c("both", "min_x", "max_x", "none"),
  sorting = c("none", "onset", "inside_out"),
  ...
)

Arguments

mapping

provide you own mapping. both x and y need to be numeric.

data

provide you own data

geom

change geom

position

change position

show.legend

show legend in plot

inherit.aes

should the geom inherits aesthetics

na.rm

remove missing values

bw

bandwidth of kernel density estimation

extra_span

How many extra range should be used in estimation? Percent of x range added to min and max.

n_grid

number of x points that should be calculated. The higher the more smooth plot.

method

Only 'new wiggle' is implemented so far.

center_fun

a function that returns the y center for each possible x in range of x.

type

one of 'mirror' which stacks symmetrically around the x axis, or 'ridge' which stacks from the x-axis, or 'proportional'

true_range

should the true data range be used or the estimation range?

sorting

Should the groups be sorted. Either the default 'none', 'onset' or 'inside_out'

...

other arguments to be passed to the geom

Value

a 'ggplot' layer

Examples

library(ggplot2)
set.seed(123)
 df <- data.frame(x = rep(1:10, 3),
                  y = rpois(30, 2),
                  group = sort(rep(c("A", "B", "C"), 10)))
ggplot(df, aes(x, y, fill = group, label = group)) +
  geom_stream()

geom_stream_label geom to create labels to a geom_stream plot

Description

geom_stream_label

geom to create labels to a geom_stream plot

Usage

geom_stream_label(
  mapping = NULL,
  data = NULL,
  geom = "text",
  position = "identity",
  show.legend = NA,
  inherit.aes = TRUE,
  na.rm = TRUE,
  bw = 0.75,
  extra_span = 0.01,
  n_grid = 100,
  method = c("new_wiggle"),
  center_fun = NULL,
  type = c("mirror", "ridge", "proportional"),
  true_range = c("both", "min_x", "max_x", "none"),
  sorting = c("none", "onset", "inside_out"),
  ...
)

Arguments

mapping

provide you own mapping. both x and y need to be numeric.

data

provide you own data

geom

change geom

position

change position

show.legend

show legend in plot

inherit.aes

should the geom inherits aesthetics

na.rm

remove missing values

bw

bandwidth of kernel density estimation

extra_span

How many extra range should be used in estimation? Percent of x range added to min and max.

n_grid

number of x points that should be calculated. The higher the more smooth plot.

method

Only 'new wiggle' is implemented so far.

center_fun

a function that returns the y center for each possible x in range of x.

type

one of 'mirror' which stacks symmetrically around the x axis, or 'ridge' which stacks from the x-axis, or 'proportional'.

true_range

should the true data range be used or the estimation range?

sorting

Should the groups be sorted. Either the default 'none', 'onset' or 'inside_out'

...

other arguments to be passed to the geom

Value

a 'ggplot' layer

Examples

library(ggplot2)
set.seed(123)
 df <- data.frame(x = rep(1:10, 3),
                  y = rpois(30, 2),
                  group = sort(rep(c("A", "B", "C"), 10)))
ggplot(df, aes(x, y, fill = group, label = group)) +
  geom_stream() +
  geom_stream_label(n_grid = 100)