performance_plot {eiExpand}R Documentation

Performance Analysis Plotting Function

Description

Uses output from performance() to create a ggplot performance analysis visualization.

Usage

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
)

Arguments

perfDF

A data.frame object containing performance analysis results from performance()

title

The plot title

subtitle

The plot subtitle

legend_name

The legend title

preferred_cand_races

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.

colors

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.

breaks

Numeric vector containing x axis breaks

lims

Numeric vector containing x axis limits

bar_size

The size of plot bars. Passed to geom_linerange().

label_size

The size of vote share labels

position_dodge_width

The width value passed to position_dodge(). Affects spacing between the plot bars.

cand_name_size

Text size of candidate names if includeCandName = TRUE

cand_name_pad

Padding between candidate name and y axis if includeCandName = TRUE.

contest_name_size

Text size of contest name

contest_name_pad

Padding between contest name and y axis

panel_spacing

space between panels. This argument is relevant only if there are multiple jurisdictions in perfDF.

panelBy

Column name from perfDF passed to facet_grid() to create panels. Recommended options are Jurisdiction and Map. Defaults to Jurisdiction.

includeCandName

Logical indicating if candidate names should appear on the left side of the plot.

includeMeanDiff

Logical indicating if the mean difference between preferred_candidate across all elections should appear in the plot.

Value

ggplot visualization of performance analysis

Author(s)

Rachel Carroll <rachelcarroll4@gmail.com>

See Also

performance

Examples

library(eiExpand)
data(example_performance_results)
performance_plot(example_performance_results)

#ggplot2::ggsave("perf_plot.png", width = 12, height = 7)

[Package eiExpand version 1.0.5 Index]