| library(cowplot) |
| library(ggplot2) |
|
|
| |
| |
| |
|
|
| |
| partisan_colors <- list( |
| republican = "#D32F2F", |
|
|
| democrat = "#1976D2", |
| independent = "#388E3C", |
| total = "#424242", |
| reference = "#757575", |
| cautious = "#7B1FA2" |
| ) |
|
|
| |
| |
| get_partisan_colors <- function() { |
| c( |
| "Republican" = partisan_colors$republican, |
| "Democrat" = partisan_colors$democrat, |
| "Independent" = partisan_colors$independent, |
| "Republicans" = partisan_colors$republican, |
| "Democrats" = partisan_colors$democrat, |
| "Independents" = partisan_colors$independent, |
| "Total" = partisan_colors$total, |
| "Republicans Infected" = partisan_colors$republican, |
| "Democrats Infected" = partisan_colors$democrat, |
| "Independents Infected" = partisan_colors$independent |
| ) |
| } |
|
|
| |
| |
| get_model_linetypes <- function() { |
| c( |
| "Reference Model" = "dashed", |
| "Current Model" = "solid", |
| "Best Case Model" = "dotted", |
| "Homogenous" = "dashed" |
| ) |
| } |
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| theme_partisan <- function(base_size = 14, title_size = 16) { |
| theme_cowplot(font_size = base_size) + |
| theme( |
| |
| plot.title = element_text( |
| size = title_size, |
| face = "bold", |
| color = "#424242", |
| margin = margin(b = 8) |
| ), |
| plot.subtitle = element_text( |
| size = base_size - 1, |
| color = "#616161", |
| margin = margin(b = 8), |
| lineheight = 1.3 |
| ), |
|
|
| |
| axis.title = element_text(size = base_size - 1, color = "#424242"), |
| axis.text = element_text(size = base_size - 2, color = "#616161"), |
| axis.line = element_line(color = "#BDBDBD", size = 0.5), |
|
|
| |
| panel.grid.major.y = element_line(color = "#EEEEEE", size = 0.3), |
| panel.grid.major.x = element_blank(), |
| panel.grid.minor = element_blank(), |
|
|
| |
| legend.background = element_rect(fill = "white", color = NA), |
| legend.title = element_text(size = base_size - 1, face = "bold"), |
| legend.text = element_text(size = base_size - 2), |
|
|
| |
| plot.background = element_rect(fill = "white", color = NA), |
| panel.background = element_rect(fill = "#FAFAFA", color = NA), |
|
|
| |
| plot.margin = margin(t = 10, r = 10, b = 10, l = 10) |
| ) |
| } |
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| get_legend_35 <- function(plot, legend = NULL) { |
| |
| tryCatch({ |
| leg <- cowplot::get_legend(plot) |
| return(leg) |
| }, error = function(e) { |
| return(NULL) |
| }) |
| } |
|
|