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 |
The Worldwide Blockbusters 2019-1977 dataset provides information on the top ten highest grossing films worldwide between the years 2019 and 1977.
blockbusters
blockbusters
A data frame with 430 rows and 4 variables:
release year of blockbuster
genre of blockbuster title
Sum of box office per genre and year, billion real dollars
https://www.kaggle.com/narmelan/top-ten-blockbusters-20191977
geom_stream
geom to create stream plots
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"), ... )
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"), ... )
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 |
a 'ggplot' layer
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()
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
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"), ... )
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"), ... )
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 |
a 'ggplot' layer
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)
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)