ggplot_streamgraph | R Documentation |
Creates a ggplot2 streamgraph based on ggstream::geom_stream()
using the specified period
as time
resolution.
ggplot_streamgraph(
data,
by,
period = c("week", "month", "quarter", "year", "decade", "century"),
stacking = c("mirror", "ridge", "proportional"),
bandwidth = 0.75,
y_lim = NULL,
color_palette = viridisLite::turbo,
prune_legend = TRUE
)
data |
RDB referendum data as returned by |
by |
|
period |
Type of period to count referendums by. One of
|
stacking |
Stacking type. One of
|
bandwidth |
Kernel density estimation bandwidth. A numeric scalar. |
y_lim |
Optional Y axis range limit. Only relevant if |
color_palette |
Color palette function that when called with a single integer argument returns that many color codes. |
prune_legend |
Whether or not to drop |
A ggplot2 object.
Other visualization functions:
plot_rfrnd_share_per_period()
,
plot_topic_segmentation()
,
plot_topic_share_per_period()
data_rdb <- rdb::rfrnds(quiet = TRUE)
rdb::ggplot_streamgraph(data = data_rdb,
by = topics_tier_1,
period = "year")
# you can specify a different color palette
rdb::ggplot_streamgraph(data = data_rdb,
by = topics_tier_1,
period = "year",
color_palette = viridisLite::viridis)
# by default, only factor levels which occur in data are included in the legend
data_rdb |>
dplyr::filter(country_code == "AT") |>
rdb::ggplot_streamgraph(by = topics_tier_1,
period = "decade")
# but you can include *all* factor levels in the legend if you want to
data_rdb |>
dplyr::filter(country_code == "AT") |>
rdb::ggplot_streamgraph(by = topics_tier_1,
period = "decade",
prune_legend = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.