sg_legend: Modify streamgraph legend properties

Description Usage Arguments Details Examples

View source: R/legend.r

Description

If the streamgraph is interactive, a "legend" can be added that displays a select menu of all the stream categories. Selecting a category will highlight that stream in the graph.

Usage

1
sg_legend(sg, show = FALSE, label = "")

Arguments

sg

streamgraph object

show

if this is TRUE and interactive is TRUE then a popup menu will be available that lists ll the keys in the data set. Selecting a key will perform the same action as hovering over the area with the mouse.

label

label for the legend (optional)

Details

TODO: legends for non-interactive streamgraphs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
library(dplyr)
library(streamgraph)
ggplot2movies::movies %>%
select(year, Action, Animation, Comedy, Drama, Documentary, Romance, Short) %>%
  tidyr::gather(genre, value, -year) %>%
  group_by(year, genre) %>%
  tally(wt=value) %>%
  ungroup %>%
  mutate(year=as.Date(sprintf("%d-01-01", year))) -> dat

streamgraph(dat, "genre", "n", "year") %>%
  sg_fill_brewer("PuOr") %>%
  sg_legend(TRUE, "Genre: ")

## End(Not run)

hrbrmstr/streamgraph documentation built on May 17, 2019, 5:14 p.m.