Uses output from performance() to create a ggplot
performance analysis visualization.
performance_plot(
perfDF,
title = "Performance Analysis Results",
subtitle = NULL,
legend_name = "Preferred Candidate:",
preferred_cand_races = NULL,
colors = NULL,
breaks = seq(0, 100, 20),
lims = c(0, 100),
bar_size = 5,
label_size = 4,
position_dodge_width = 0.8,
cand_name_size = 6,
cand_name_pad = -1,
contest_name_size = 20,
contest_name_pad = NULL,
panel_spacing = 0.7,
panelBy = "Jurisdiction",
includeCandName = TRUE,
includeMeanDiff = TRUE
)ggplot visualization of performance analysis
A data.frame object containing performance analysis results
from performance()
The plot title
The plot subtitle
The legend title
A character vector of the unique races contained
in the preferred_candidate column of perfDF. This argument is
optional and is used with colors to indicate the color of the plot
associated with the race preferences.
Plot colors for the voter race groups. Colors must
be listed in the desired order with respect preferred_cand_races if
arguments are used together.
Numeric vector containing x axis breaks
Numeric vector containing x axis limits
The size of plot bars. Passed to geom_linerange().
The size of vote share labels
The width value passed to position_dodge().
Affects spacing between the plot bars.
Text size of candidate names if includeCandName = TRUE
Padding between candidate name and y axis if
includeCandName = TRUE.
Text size of contest name
Padding between contest name and y axis
space between panels. This argument is relevant only if
there are multiple jurisdictions in perfDF.
Column name from perfDF passed to facet_grid() to
create panels. Recommended options are Jurisdiction and Map.
Defaults to Jurisdiction.
Logical indicating if candidate names should appear on the left side of the plot.
Logical indicating if the mean difference between preferred_candidate across all elections should appear in the plot.
Rachel Carroll <rachelcarroll4@gmail.com>
performance
library(eiExpand)
data(example_performance_results)
performance_plot(example_performance_results)
#ggplot2::ggsave("perf_plot.png", width = 12, height = 7)
Run the code above in your browser using DataLab