gg_survey: Plot voter shares observed in one survey
Description
Bar chart of the raw voter shares observed in one survey.
Additionally to plotting positive voter shares,
the function can be used to plot party-specific differences (e.g. between
a survey and the election result), including negative numbers.
Usage
gg_survey(data, colors = NULL, labels = NULL, annotate_bars = TRUE, hurdle = 5)
Arguments
- data
Scraped dataset containing one row per party in the column
party
and the observed voter share in the column percent
- colors
Named vector containing party colors. If NULL
(default) tries to guess color based on party names, gray otherwise.
- labels
Named vector containing party labels. If NULL
(default)
tries to guess party names from data
.
- annotate_bars
If TRUE
(default) bars are annotated by the
respective vote share (percentage).
- hurdle
Hurdle for single parties to get into the parliament, e.g. '5'
for '5%'. If set to NULL no horizontal line is plotted.
The horizontal line can be suppressed using NULL
.
Examples
Run this codelibrary(tidyr)
library(dplyr)
library(coalitions)
survey <- surveys_sample$surveys[[1]]$survey[[1]]
gg_survey(survey)
Run the code above in your browser using DataLab