Description Usage Arguments Examples
Create an Electoral Snake Plot
1 |
data |
data frame |
order |
variable to use to order the snake segments |
label |
variable to use to label the segments (also used as a grouping variable) |
fill |
variable to use to fill the segments in |
color |
variable to use to outline the segments |
size |
variable to use to determine how many segments are allocated to a group |
1 2 3 4 5 6 | library(dplyr)
electoral_votes_2016 %>%
mutate(diff = perc_rep - perc_dem, party = ifelse(perc_dem > perc_rep, "Dem", "Rep"),
label = clean_districts(state_district, electoral_votes)) %>%
ggsnake(order = diff, fill = diff, label = label, color = party, size = electoral_votes) +
scale_fill_party_binned() + scale_color_party()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.