In R, I use a self-generated data frame of parties with their seats in an election.
The problem is that the parliament plot is generated correctly, but the points that form the plot are shown in black and I cannot display them with the color that corresponds to the data of the parties. Please help me.
The formula and the dataframe:
library(ggplot2)
library(ggparliament)
library(readxl)
library(dplyr)
colors = c("#783736","#7ca32f","#b59f5c","#7ed61a","#a546bd","#337d34")
parties <- c("PC","FRVS","PH","PEV","COM","CS")
seats <- c(10,2,3,2,6,7)
datos <- data.frame(parties,seats,colors)
parties seats colors
1 PC 10 #38ebe8
2 FRVS 2 #2979cf
3 PH 3 #1f1f9c
4 PEV 2 #7022ab
5 COM 6 #181644
6 CS 7 #e01624
I used this formula to generate a parliament plot:
congress1 <- parliament_data(election_data = datos,
type = "semicircle",
parl_rows = 6,
party_seats = datos$seats)
cl <- ggplot(congreso1, aes(x = x, y = y, fill = colors)) +
geom_parliament_seats(size=3.5) +
theme_ggparliament() +
labs(fill = NULL,
title = "Parliament Seats") +
scale_fill_manual(values = datos$colors,
limits = datos$parties)
cl