Volume 1 BBC Style Graph

# install.packages('devtools')
devtools::install_github('bbc/bbplot')
Using GitHub PAT from the git credential store.
Skipping install of 'bbplot' from a github remote, the SHA1 (82af5952) has not changed since last install.
  Use `force = TRUE` to force installation
devtools::install_github("zmeers/ggparliament")
Using GitHub PAT from the git credential store.
Skipping install of 'ggparliament' from a github remote, the SHA1 (169da8e5) has not changed since last install.
  Use `force = TRUE` to force installation
#loading libraries in R
library(readxl)
library(tidyverse)
Warning: package 'ggplot2' was built under R version 4.4.3
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.2     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(bbplot)
library(ggparliament)
df <- read_excel("Data/2079 NP Election.xlsx")
df %>%
  mutate(party_color = case_when(
                        Party == "Nepali Congress" ~ "#66f04a",
                        Party == "CPN-UML" ~ "#fa7619",
                        Party == "Maoist" ~ "#910101",
                        Party == "CPN(US)" ~ "#d98a52",
                        Party == "Rastriya Prajantantra Party" ~ "#ebe710",
                        Party == "Rastriya Swatantra Party" ~ "#59320b",
                        Party == "Loktantrik Smajbadi Party" ~ "#11d19b",
                        Party == "Nagarik Unmukti Party" ~ "#3b2208",
                        Party == "Nepal Workers and Peasants Party" ~ "#c71c44",
                        Party == "Janamat Party" ~ "#4a2d34",
                        Party == "Rastriya Janamorcha" ~ "#e80004",
                        Party == "Independent" ~ "#a5d9fa",
                        Party == "Janata Samajbadi Party" ~ "9053e6")) -> df
#
df_graph <- parliament_data(election_data = df,
                            type = "semicircle",
                            parl_rows = 8,
                            party_seats=df$Total)
df_graph %>%
  ggplot(aes(x=x,y=y, colour = Party)) +
  geom_parliament_seats(size = 5) -> df_graph_output
df_graph_output

df_graph_output + bbplot::bbc_style() +
  ggtitle("Nepal Parliament 2022") +
  theme(text = element_text(size=10),
        legend.title = element_blank(),
        axis.text.x = element_blank(),
        axis.text.y = element_blank()) +
        scale_colour_manual(values = df$party_color,
                            limits = df$Party)
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database